Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with Set analysis between 2 numbers

Hi,

I'm trying to write an expression with set analysis that will  sum the number of Sales (IsSale) if the Sale age is between 0 and 30

Here is what I have so far but it isn't working out

Sum({$<SaleAge={>=(0)<=(30)>} IsSale)

What am I doing wrong, what is the correct syntax?

Thanks for the help.

3 Replies
maxgro
MVP
MVP

Sum({$<SaleAge={">=0<=30"}>} IsSale)

VishalWaghole
Specialist II
Specialist II

Hi Brian,

Try this logic,

sum({<SalesAge = {">=0"}, SalesAge = {"<=30"}>}Sales)

this will help you and also find attached application.

-- Regards,

Vishal Waghole

emiledavis
Contributor III
Contributor III

I know this post is several years old now, but I'll add to Massimo's solution (thank you by the way)...

Depending on your application and what it may be used for, using a variable for this would make the formula more dynamic.  Note that the extra '=' sign and the '+0' isn't necessary.  But I like to setup the expression like this because it makes shifting the value easy. I use this method to do a rolling 12 months calculation.

Sum({$<SaleAge={">=0<=30"}>} IsSale)                                                      //Static


Sum({$<SaleAge={">=$(=vMinAge-0)<=$(=vMaxAge-0)"}>} IsSale)          //Dynamic


I use this method  to do a rolling 12 months calculation.

Sum({$<SaleAge={">$(=vCurrentMonth-12)<=$(=vCurrentMonth-0)"}>} IsSale)


Hope this is useful to somebody out there! 🙂

Emile