Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

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
Valued Contributor

Re: Previous Month Expression

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

Not applicable

Re: Previous Month Expression

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

Not applicable

Re: Previous Month Expression

hope it works

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

Not applicable

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.

manideep78
Valued Contributor

Re: Previous Month Expression

Try this

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

Hope it helps

Not applicable

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

manideep78
Valued Contributor

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

Not applicable

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

Month          [Total Licenses]     [Last Month]

Dec-2012     95                          -

Jan-2013     100                         95

Feb-2013     105                        100

Mar-2013     120                         105

Not applicable

Re: Previous Month Expression

Hi Michael,

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

Community Browser