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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
abhaysingh
Specialist II
Specialist II

Set Expression Help

Hi ,

i have to show Max Month Sales, previous month sale and previous to previous month sales.

i created 3 variables

vMaxMonth = max(Month)                /// month value are in number

vlastMonth = Max(Month)-1

vlast2lastMonth = Max(Month)-2

now i am using variable in this way.

=sum({< Month = {$(vMaxMonth)}>}sales

=sum({< Month = {$(vlastMonth )}>}sales

please correct me it is not working

11 Replies
er_mohit
Master II
Master II

Hi

Try this but make sure your Date have same format

sum({<Date = {'>=$(=MonthStart(Max(Date), -3))<=$(=MonthEnd(Max(Date)-1))'},Year=,Month=>}Sale)

tobias_klett
Partner - Creator II
Partner - Creator II

Hi Abhay,

note that your Month-Field is dual with e.g. a text "Feb" and a number "2".
When using it in Set Analysis you can write {Jan,Feb} or {'<3'}. Both with the same result.

Therefore you need to convert the result of your Variables into the text again like this:

=month(date#(max(Month),'MM'))   or   =month(makedate(2000,max(Month),1))

or alternatively you can write your set Statement like this:

=sum({<Month={'<=$(vMaxDate)>=$(vMaxDate)}>}sales)

Hope this helps

Tobias