Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis - Last 3 Months of Last Year

Here is my current syntax that is not working.

=sum({$<Year={$(=Max(Year)-1)}, MonthID = {">$(#=max(MonthID)-3) <=$(#=max(MonthID))"}> }Cnt)

What am I doing wrong?

10 Replies
Not applicable
Author

here's a pointer: Last 3 months will always be specific - like Oct, Nov & Dec if you're using Calendar year....if you're using Fiscal year, then whatever are the last 3 months according to your FY. So you could be more specific with the months or MonthIDs in the set exp above.

Not applicable
Author

I would like the expression to grab the last 3 months from the current date. Then they would be able to select April, and get Feb, March, April. MonthID's 1,2,3.

Is that what your looking for?

Not applicable
Author

Please try the below expression:

=sum({$<Year={"$(=Max(Year)-1)"}, MonthID = {">$(=max({<Year={"$(=Max(Year)-1)"}>} MonthID)-3) <=$(=max({<Year={"$(=Max(Year)-1)"}>} MonthID))"}> }Cnt)

Kiran.

Not applicable
Author

So that value that is close, but it off just a little bit. It looks like it is a date issue.

But its a good start, thanks.

Not applicable
Author

Also, this works fine with no selections, but say I select April. I would like to see that last 90 days from that point. How would the expression need to be changed for that scenario?

Not applicable
Author

Also, I forgot to add this titbit.

This is a variable I'm using for current year rolling 3 months.

This is the expression I'm using

=sum($(vSetRolling3)Cnt)

Let vSetRolling3 = '{$<MonthID = {">=' & Chr(36) & '(=Max(MonthID) - 2)<=' & Chr(36) & '(=Max(MonthID))"},' & Chr(10) &

                                        'Date = ,' & Chr(10) &

                                        'Year = ,' & Chr(10) &

                                        'Quarter = ,' & Chr(10) &

                                        'Period = ,' & Chr(10) &

                                        '[Period (#)] = ,' & Chr(10) &

                                        'Month = >}';

But I couldn't figure out how to drop the variable into the expression to make it last year. I'm sorry that I forgot to add this earlier.

Not applicable
Author

=sum({$<Date={"<=$(=Max(Date)-90)"}} Cnt). Hoping you have a date fields on which you created calender fields.

Kiran

Not applicable
Author

This expression does not work for me.....

Not applicable
Author

Try this:

Sum ({$<MonthYear={"<=$(=date(addmonths(max(MonthYear),-12),'MMM-YYYY'))>=$(=date(addmonths(max(MonthYear),-14),'MMM-YYYY'))"}, Year=, Month=>} [Sales Amount])