Former Member

# Sum a by previous month's date range

Hello,

i am having trouble creating a formula for the following.

sum(,,) in minimum(Lastfullmonth)-1 and in maximum(Lastfullmonth)-1

can anyone help me out with this formula?

thanks

david

Edited by: davitali on Nov 22, 2011 2:54 AM

10|10000 characters needed characters exceeded

### Related questions

Former Member
Posted on Nov 23, 2011 at 12:46 AM

Hello,

I cannot still work this out.. what i am trying to achieve is simply

calculate a months total, then calculate the prior months total and display the difference...

10|10000 characters needed characters exceeded
• Abhilash Kumar Former Member

Hi David,

If you're using CR 2008, you can make use of the advanced cross-tab features available.

Follow the steps below to create a calculated member (a.k.a row or column):

1) In the Preview mode, right-click the column header that shows the last month. Considering September as the last month, Right-click the column header > Calculated Member > Insert Column

2) A column with a blank header and zero values comes up after September

3) Right-click the blank column header and select Calculated Member > Edit Header Formula. Type this in the editor:

"Difference"

4) Now, the blank column header displays the text 'Difference'

5) Next, right-click one of the zero values in this column and select Calculated Member > Edit Calculation Formula. Type this formula:

`Gridvalueat(currentrowindex,currentcolumnindex-1,currentsummaryindex) - Gridvalueat(currentrowindex,currentcolumnindex-2,currentsummaryindex)`

The Crosstab would now display the difference between the two months.

To change the font color of the value try this:

1) Right-click one of the values from the column and select Format Field > Font tab > click the formula button beside Color and use this formula:

```if CurrentColumnIndex = 1 then
(
if currentfieldvalue < Gridvalueat(currentrowindex,currentcolumnindex-1,currentsummaryindex)
then crRed else crGreen
)
else
crNoColor```

If you have not suppressed the Row Totals or if the Row Totals is the 1st Column, then the formula might color the column beside Total (October) instead of the last (September). Just change the value of CurrentColumnIndex in the above formula to 2.

Let me know how this goes!

-Abhilash

• Former Member
Posted on Nov 22, 2011 at 02:51 AM

ok,

i have come up with this but it does not work.. lol

if {zsalesdata_.Created_On} in maximum(LastFullMonth)-1 to minimum(LastFullMonth)-1 then sum({zsalesdata_.Net_value},{zfms_accman2_.SearchTerm2})

else 0

i am trying to report on not last month (October), but the previous month (September).

10|10000 characters needed characters exceeded
• Abhilash Kumar Former Member

Hi David,

Alright, here's the record selection formula you need to use:

`Month({zsalesdata_.Created_On}) in [Month(currentdate)-1, Month(currentdate)-2]`

Hope this helps!

-Abhilash

• Former Member
Posted on Nov 22, 2011 at 10:07 PM

thanks for the reply. I still dont think this is correct. The above formula selects the record data for the past 2 months, but i am after the formula two display two seperate columns with the totals sum of each month...

e.g

October September

\$2089 \$5858

Once this is done i can create a third column called "difference"..

10|10000 characters needed characters exceeded
• Ohh, sorry, I thought you were now looking for a record selection formula. Could you try this formula:

```if Month({zsalesdata_.Created_On}) in [Month(currentdate)-1, Month(currentdate)-2] then sum({zsalesdata_.Net_value},{zfms_accman2_.SearchTerm2})
else 0```

-Abhilash

• Former Member
Posted on Nov 23, 2011 at 04:39 AM

Wow,

that was awsome.. worked a charm.

Thank you very much for your help and support.