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

set analysis greater than less than question

Hi,

I am trying the below expression. I want to use the greater than less in set analysis and I also need to apply num function over the modifier

sum({<Year={"=$(=Year(max(s_date)))"},Month = {"=num(Month)>=$(=Addmonth(max(s_date),-9)) <=$(=Addmonth(max(s_date),-1)) "}>} revenue)

Can someone please help me fix this syntax.

Regards

Shah

3 Replies
maxgro
MVP
MVP

If you have a calendar with a month serial field, like this

load

    d,                                                        // date

    year(d) as y,                                        // year

    month(d) as m,                                    // month

    year(d)*12 + month(d) as mserial,          // month serial

    ceil(rand()*100) as revenue

;

load

  date(makedate(2015) + iterno()-1) as d

AutoGenerate 1

While IterNo() <= 730;



you can use the expression

sum({$ <y=,m=,mserial={">=$(=max(mserial)-8)<=$(=max(mserial))"}>} revenue)

and that also works crossing years

1.png





Not applicable
Author

Thanks for the solution. My problem is that I do not have access to the loading script or the data behind it so the only way for me to do is using the set analysis expression

Secondly It would be also good for me from learning perspective to see how we can do it inside set analysis

For example, I know how to use greater than less than in set analysis and I also know how to apply a function to a modifier by doing something for example Month =  {"=Num(Month) <= 2"}

However, I dont know how to combine these two expressions so I will appeciate if someone can help me using set analysis

maxgro
MVP
MVP

for revenue between max date - 9 months and max date

sum({$ <Year=,Month=,s_date={">=$(=addmonths(max(s_date),-9))<=$(=max(s_date))"}>} revenue)