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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
brunolelli87
Creator II
Creator II

Sum the last 4 values

Hello guys,

I'm here again facing lots of problems trying to use QlikView...

How can I sum the last 4 values different to zero?

Check this sample chart:

DateLOPPThis is what I'm looking for
18/05/202003+1+5+3 = 12
17/05/202031+5+3+1 = 10
16/05/202001+5+3+1 = 10
15/05/202015+3+1 = 9
14/05/202053+1 = 4
13/05/202003+1 = 4
12/05/202003+1 = 4
11/05/202031 = 1
10/05/20201-

 

How can I do it?
Thanks

5 Replies
brunolelli87
Creator II
Creator II
Author

Any Help?

Vegar
MVP
MVP

Maybe you can do the expression Sum(LOPP), but in the table expression properties choose to accumulate by 4 steps. 

Read more inain the Accumulation section in this help page: https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Straight_Table....

brunolelli87
Creator II
Creator II
Author

Hello Vergar, how are you?

Thanks for your help, but it's not working!

I believe the solution is easier than I'm trying to explain, but It's difficult to explain by text.
Are you available for a 30 minutes call via Skype?


Thanks for your time

Saravanan_Desingh

One solution in

SET DateFormat='D/M/YYYY';

tab1:
LOAD * INLINE [
    Date, LOPP
    18/5/2020, 0
    17/5/2020, 3
    16/5/2020, 0
    15/5/2020, 1
    14/5/2020, 5
    13/5/2020, 0
    12/5/2020, 0
    11/5/2020, 3
    10/5/2020, 1
]
;

tab2:
LOAD *, RangeSum(K1, K2, K3, K4) As Last4Sum
;
LOAD *, If(Peek('LOPP')=0,Peek('K1'),Peek('LOPP')) As K1
	  , If(Peek('LOPP')=0,Peek('K2'),Peek('K1')) As K2
	  , If(Peek('LOPP')=0,Peek('K3'),Peek('K2')) As K3
	  , If(Peek('LOPP')=0,Peek('K4'),Peek('K3')) As K4
Resident tab1
Order By Date
;	  	  	  

Drop Table tab1;

 

Script:

 

Saravanan_Desingh

commQV02.JPG