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

Running total (again)...

In this helpfull forum I  found an expression that seems to be the solution for what I am looking for.

This is the expression :

=sum(aggr(rangesum(above(total sum({<yearmonthnumber= >}WTF_Totaal),0,12)),yearmonthnumber))

I get strange results however.The cumulative sum has the wrong order.  In my app I only have one table. For every %key_kpl /yearmonthnumber there is only one value. No matter what %key_kpl I select, the cumulative sum gets the wrong order at yearmonthnumber 24223.

Yearmonthnumber is calculated in my load script  2018*12+num(right(period,2))  where period is  '2018-05' for example.

When I reduce the number of %key_kpl to one or two  then the cumulative values are correct. So I assume it has something to do with the sorting in the load script, I tried several sorting but cumulatives remain wrong.

I spent several hours figuring out what the reason of this error can be, but now I am out of ideas.

I hope someone can give me a hint on how to solve this. We are version 12.10.20600.0. of Qlikview

%key_kplyearmonthnumber**bleep**  WTF_Totaal=WTF_Totaal'
2018-5300242172.502.50
2018-5300242185.002.50
2018-5300242197.502.50
2018-53002422010.002.50
2018-53002422112.502.50
2018-53002422215.002.50
2018-53002422327.502.50
2018-53002422430.002.50
2018-53002422517.502.50
2018-53002422620.002.50
2018-53002422722.502.50
2018-53002422825.002.50

 

 

10 Replies
curiousfellow
Specialist
Specialist
Author

load * inline [
%key_kpl	,yearmonthnumber	,	WTF_Totaal
2018-5300,24217,25
2018-5300,24218,25
2018-5300,24219,25
2018-5300,24220,25
2018-5300,24221,25
2018-5300,24222,25
2018-5300,24223,25
2018-5300,24224,25
2018-5300,24225,25
2018-5300,24226,25
2018-5300,24227,25
2018-5300,24228,25
2018-5300,24229,25
2018-5300,24230,25
2018-5300,24231,25
2018-5300,24232,25
2018-5300,24233,25
2018-5301,24217,25
2018-5301,24218,25
2018-5301,24219,25
2018-5301,24220,25
2018-5301,24221,25
2018-5301,24222,25
2018-5301,24223,25
2018-5301,24224,25
2018-5301,24225,25
2018-5301,24226,25
2018-5301,24227,25
2018-5301,24228,25
2018-5301,24229,25
2018-5301,24230,25
2018-5301,24231,25
2018-5301,24232,25
2018-5301,24233,25


];

And the result is below this . After yearmonthnum 24228 the running total should remain 300. (12*25)

 

%key_kplyearmonthnumber=if(above([%key_kpl])=[%key_kpl] ,rangesum(above(column(1)),WTF_Totaal),sum(WTF_Totaal))
2018-53002421725
2018-53002421850
2018-53002421975
2018-530024220100
2018-530024221125
2018-530024222150
2018-530024223175
2018-530024224200
2018-530024225225
2018-530024226250
2018-530024227275
2018-530024228300
2018-530024229325
2018-530024230350
2018-530024231375
2018-530024232400
2018-530024233425
2018-53012421725
2018-53012421850
2018-53012421975
2018-530124220100
2018-530124221125
2018-530124222150
2018-530124223175
2018-530124224200
2018-530124225225
2018-530124226250
2018-530124227275
2018-530124228300
2018-530124229325
2018-530124230350
2018-530124231375
2018-530124232400
2018-530124233425