Skip to Content
author's profile photo Former Member
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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    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...

    am i going about this the wrong way?

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo Former Member
    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).

    any advice'?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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"..

    Add a comment
    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

  • author's profile photo Former Member
    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.