Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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:

sum([Total Licenses])

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

=sum({$<[Month Key]={$(=[PM Key])}>} [Total Licenses])

[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.

14 Replies
manideep78
Partner - Specialist
Partner - Specialist

Sum({<[PM Key]>}[Total Licenses])

Not applicable
Author

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

Not applicable
Author

hope it works

sum({<Month ={$(=Max(Month)-1)}>}[Total Licenses])

Not applicable
Author

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.

manideep78
Partner - Specialist
Partner - Specialist

Try this

Sum({<[Month Key]=[PM Key]>}[Total Licenses])

Hope it helps

Not applicable
Author

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].

manideep78
Partner - Specialist
Partner - Specialist

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

Not applicable
Author

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...

Month          [Total Licenses]     [Last Month]

Dec-2012     95                          -

Jan-2013     100                         95

Feb-2013     105                        100

Mar-2013     120                         105

Not applicable
Author

Hi Michael,

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