Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

what about current month and prior month

Hi ,

I would like to compare the data between current month and last month as below example, what about the expression about the statement?

Company NameYearMonthCurrentMonth(Qty)
A20141112
A20141215
A201518
A201526
B20141113
B2015122
B2015216
B2015314

I tried following statement, but it does not work.

CurrentMonth(Qty) : sum(stocks)

LastMonth(Qty): sum(${<Month={${=Max(Month)-1} sales )

Expecting result is like :

When select year2015, month 1, it would be

Company NameYearMonthCurrentMonth(Qty)LastMonth(Qty)
A20151815
B201512213

Pls kindly help.

Thanks

Jessica

4 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

sum(${<Month={${=Max(Month)-1} sales ) won't work because when you select month 1  then the previous month would be 1 - 1 = 0. Month 0 doesn't exist. You want month 12 of the previous year. So if you select a year and a month your expression needs to overrule those selections, because month 12 of the previous year doesn't exist in the year you selected.


If you have a date field in your data you probably can use that instead:

sum({$<Year=,Month=,Date={'>=$(=monthstart(max(Date),-1))<$(=monthstart(max(Date)))'}>}sales)


If you can't get it to work, post a qlikview document that demonstrates the problem.


talk is cheap, supply exceeds demand
Not applicable
Author

Hello Gysbert,

Attached pls find the orignial QV file, maybe we need to sumary total amount value of each month firstly, since there are multipl value in some of months. I tried your expression, it is still not working. Kindly pls help to check.

Thank you!

Regards,

Jessica

Not applicable
Author

Hi Gysbert,

I am too new here and don't fine the way to upload my QVD file. Do you know how to upload it?

Thanks&Regards

Jessica

Not applicable
Author

original data is:

Snap1.gif

Expected result:

Snap2.gif

Thanks&Regards,

Jessica