Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum sales on last day of months - before seleeted month

Hi,

I need to sum the sales of all last day of 12 months before and including the month I have chosen.

So if I choose Mars 2012 it should give me sales of last day for Mars 2012 and 11 preceding months.

With this

 

SUM({$< Date = {'=Date=aggr(nodistinct MaxString(Date),MonthYear)'}, MonthYear = {">=$(=Date(monthname(Max(MonthYear),-11),'MMM-YYYY'))<=$(=Max(MonthYear))"}>}Sales)

I get what I want as long as I dont make a selection, so I will get the end of month-sales for 12 months up to the current one.

But if I choose Mars 2012 I will only get the result for Mars 2012 and nothing else. I understand that it behaves like that because of the aggr-function that will only give me a Date for the MonthYear I have chosen, but how do I do to get the Dates for all months no matter the selection and then use the MonthYear-definition like I have done above.

Or better still, use only the Date-definition but in it also make sure to only get the 12 months including and before the current selected.

Kind regards

Peter

0 Replies