14 Replies Latest reply: Mar 11, 2013 1:12 PM by Michael Todd

# Previous Month Expression

Hi,

Please can someone help me with calculating the previous month expression.  I have a straight table with number of licenses calculated by:

Against this I want to show the same value for the previous month, so I written the below expression:

[Month Key] is held on every record to show the month e.g. 3_2012.

[PM Key] is also held on every record to show the previous month e.g. 2_2012.

but not working :-<

Grateful for any assitance with this.

Mike.

• ###### Re: Previous Month Expression

Thanks Manideep but this just gives the same total as the current month value.

• ###### Re: Previous Month Expression

hope it works

• ###### Re: Previous Month Expression

Sorry but no joy with that either.  Can't do a "month -1" because my month is a string.  Even with integers this would not deal with January correctly.

• ###### Re: Previous Month Expression

Try this

Hope it helps

• ###### Re: Previous Month Expression

Thanks but still no joy.  I think that expression would look for [Total Licenses] where [Month Key] = "PM Key"... this will never be true.  I think it needs to be where the value of [PM Key] = [Month Key].

• ###### Re: Previous Month Expression

What does your [Month Key] represents? what is the actual data int that field? Does your [PM Key] represents only your previous month data???

• ###### Re: Previous Month Expression

Let me give an example:

[Month Key]     [Total Licenses]     [PM Key]

12_2012          95                          11_2012

1_2013            100                        12_2012

2_2013            105                        1_2013

3_2013            120                         2_2013

.. this should then be displayed in a straight table as...

Dec-2012     95                          -

Jan-2013     100                         95

Feb-2013     105                        100

Mar-2013     120                         105

• ###### Re: Previous Month Expression

Hi Michael,

try the above() function, eg above([Total Licences]).

• ###### Re: Previous Month Expression

Have already tried that - Above only works when the month stay in the correct sort order, and it also goes wrong when the user makes a select that excludes previous month.

• ###### Re: Previous Month Expression

The sort order thing is true - are you having problems with that? There are ways around sort problems. However, I have a previous month expression in my code and it continues to function even when the month is restricted. What code are you using?

• ###### Re: Previous Month Expression

I am displaying my table horizontally so don't think the Above() function will work for me.

• ###### Re: Previous Month Expression

In that case Before() will serve a similar purpose.

• ###### Re: Previous Month Expression

Sorry, I am acutally using a pivot table rather than a straight table so Above() or Below() will not work.