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

Showing values for previous 12 months/periods using set analysis?

Hi,

I want to make a chart with the sum of "quantity" for the current period and for 11 previous periods. I.e. 12 months/periods.

I'm using the following expression in a chart:

=



sum({$<created_per={$(=Max(created_per))}>}quantity)

created_per is the period in format YYYYMM. This expression works fine, and shows the latest period in my chart.

However, if i write expressions like this for each record:







= sum({$<created_per={$(=Max(created_per)-1)}>}quantity)

= sum({$<created_per={$(=Max(created_per)-2)}>}quantity)

= sum({$<created_per={$(=Max(created_per)-3)}>}quantity)





It does not work, because when subtracting 1 from the period 201101, it becomes 201100 - which obviously is not a valid period. Instead of 201100 I would of course need to get 201012.

Any suggestions for how to solve this? How do I refer to the previous record in the created_per "column".

25 Replies
Not applicable
Author

Hi,

I am attaching my understanding of how to use RangeAvg,

it seems it is not working in the chart as I had hoped. It gives some result, but the result is not the average of quantity for past 3 bars.

W

tresesco
MVP
MVP

Hi,

modify the formula as : Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4 RangeAvg(Above(Sum(quantity),0,3)) or something like that.

Regards, tresesco

Not applicable
Author

Hi, that seems to give an incorrect anser. I also tried RangeSum to see if it calculates corect:

=



RangeSum(Above(Sum(quantity)),0,3)

It does not work... 😞 Any suggestions, I'm pretty much stuck here.

Not applicable
Author

Hi, that seems to give an incorrect anser. I also tried RangeSum to see if it calculates corect:

=



RangeSum(Above(Sum(quantity)),0,3)

It does not work... 😞 Any suggestions, I'm pretty much stuck here. Attached file with example.

tresesco
MVP
MVP

Hi,

Might be you are having a mistake with parenthesis, it would like RangeAvg(Above(Sum(quantity),0,3))

NOT as you wrote . please check it.

regards, tresesco

Not applicable
Author

would be helpful if the chart would have option to show LAST 12 values, to do it this way you would have to sort descending