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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem with a formula

Hi everyone:

I'm using this formula in set analysis to calculate the sales of my previous selected month:

SUM({$<Year= {$(=max(Year) - $(=if(max(Month) = 1, 1, 0)))},Month = {$(=if((Month) = 1, 12, only(Month)-1) )}, MonthYear = {"<=$(=max(MonthYear))"}>} Sales)

Does anyone can help me to modify this formula´, i need to show the sales of "N" Previous Months, because mine it only works when you select 1 month???

For example, if I select DEC,NOV,OCT of 2009, the formula has to show JUL,AUG,SEP of 2009

Regards

Carlos

11 Replies
johnw
Champion III
Champion III

OK, all it needs is for the date to be correctly formatted to match your MonthYear. In the attached example, that means putting it in MMM YYYY format. If that's the format you're using, use this:

sum({<Year=,Month=,MonthYear={"<$(=min(MonthYear)) >=$(=date(addmonths(min(MonthYear),-count(distinct MonthYear)),'MMM YYYY'))"}>} Sales)

Otherwise substitute your own format.

Not applicable
Author

Hi John:

It works perfect, thanks for all your support.

Regards,

Carlos