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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Getting previous month data

Hi All

  I having data like below

31-May

30-Apr

31-Mar

28-FEB

31-Jan

Here I need to show the bar chart based on previous month only by default. I dont have date wise data and having only month end level only

-Jai

Labels (1)
3 Replies
sunny_talwar
MVP
MVP

May be like this

Sum({<Date = {"$(=Date(Floor(MonthEnd(Max(Date), -1)), 'DD-MMM'))"}>}Measure)

jwbadger3
Contributor II
Contributor II

Sunny's expression should work but you should consider creating a variable and then referencing that variable in set analysis. That way you can re-use this in other charts or elsewhere in the app.

Another quick tip is to create a universal calendar so that you can look at previous month only (instead of a specific date) but that's not necessary.

To create a variable, I would do this in script as:

Set vLastMonth = Date(Floor(MonthEnd(Max(Date), -1)), 'DD-MMM');


Then in your expression you can simply reference this value.

Sum ( {<Date = {'$(vLastMonth)')}>} Measure)

Anonymous
Not applicable
Author

Perhaps using the Peek function to get the previous month