Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to find Previous Month Data

Please find the attached application,

Assumptions: suppose current month is April.

Problem: I need to write two expressions, First Expression will find the total amount of last month (i.e: March=1350 ) and the second expression will find the total of last three months (i.e:Feb=990,+ Mar=1350, + April=950; Total of last three months= 3290,Note : Last three months includes current month as well

Regards

Zain.

1 Solution

Accepted Solutions
sivarajs
Specialist II
Specialist II

Check the above qvw file again,but its better to use date field

View solution in original post

5 Replies
sivarajs
Specialist II
Specialist II

PFA

Not applicable
Author

thanks for the solution,

Last three months still not working well if you notice, the second expression for last three months  will give last four month's data .

sivarajs
Specialist II
Specialist II

Check the above qvw file again,but its better to use date field

Not applicable
Author

Thanks for the advice & solution .

Anonymous
Not applicable
Author

Hi Zain,

First, create a new field MONTHNUM containing month in numeric value with applymap.

Then, use variables to get appropriate month value:

_currentMonth=MONTHNUM

_previousMonth=_currentMonth-1

_previous3Month=currentMonth-3

Create expressions using thoses variables:

For last month:

Sum({$<MONTHNUM={'$(_previousMonth)'}>}AMOUNT)

For last 3 months:

Sum({$<MONTHNUM={'>=$(_previous3Month)<=$(_currentMonth)'}>}AMOUNT)

Hope it's usefull

Regards

Vincent