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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
curiousfellow
Specialist
Specialist

sum with analysis previous 11 periods and current period

I have to calculate a running average over one year for each period. Because not every dimension has values for every period, and the values of every period are not shown I cannot use the above function.

 fields in my simplified example company, period, yearmonthnum and value.

So I made an expression like this

=sum({<company={'=yearmonthnum > yearmonthnum-11'}>} value), but then I don't get any result.

 

 

 

 

2 Replies
Vegar
MVP
MVP

Try the expression
=sum({<
yearmonthnum={">=$(=max(yearmonthnum)-11)"}>} value)
curiousfellow
Specialist
Specialist
Author

Thank you for your answer, but I didn't get the result that I expect. With your expression I only get a correct result when period is not used as dimension.

When I select company A , I expect to see something like this (without the value column)

period valuerunning total
2017-05 1010
2017-06 2030
2017-07 3060
2017-08 40100
2017-09 50150
2017-10 60210
2017-11 70280
2017-12 80360
2018-01 90450
2018-02 100550
2018-03 110660
2018-04 120770
2018-05 130880
2018-06 140990
2018-07 1501100