Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

j_vergaraolguin
New Contributor II

Set analysis doesn't work

hi, I have this variable

=Max(Month)-1  (this results the number of the previus month)

and I'm trying to calculate the sales of the previous month, but the result is always 0

1 -  Sum({<Month={'$(PreviousMonth)'}>}[Sales])

2 -  Sum({<Month={$(=Max(Month)-1)}>} [Sales])

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Set analysis doesn't work

Try it with: Sum({<MonthNum={"$(=Max(MonthNum)-1)"}>} [Sales])

than not only the values must be matching the formattings, too. And in general it's recommend to use only numeric fields for such a comparing or any other calculations.

- Marcus

3 Replies
Chanty4u
Esteemed Contributor III

Re: Set analysis doesn't work

try below

1. vCurrentMonth

=Max(Month)

and make ur expression like:

sum( {$<Year = {$(#vCurrentMonth)}>} Sales )

2. vLastMonth

=Max(Month-1)

sum( {$<Year = {$(#vLastMonth)}>} Sales )

MVP & Luminary
MVP & Luminary

Re: Set analysis doesn't work

Try it with: Sum({<MonthNum={"$(=Max(MonthNum)-1)"}>} [Sales])

than not only the values must be matching the formattings, too. And in general it's recommend to use only numeric fields for such a comparing or any other calculations.

- Marcus

j_vergaraolguin
New Contributor II

Re: Set analysis doesn't work

thanks, that works