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: 
Kwame
Contributor III
Contributor III

Sum based on previous data

Hi, 

I want to sum using previous data. That is adding the previous Daily interest to the Interest  for each current day.

So, 112.83 + 0.79 = 113.62 

Any ideas guys please?

 

Sample

Transaction Date  Transaction ID  Interest  Daily Interest 
28/03/2022 1115700004 112.83 0.79

 

Desired Result

Transaction Date  Transaction ID  Interest  Daily Interest 
29/03/2022 1115700004 113.62 0.72

 

 

 

1 Solution

Accepted Solutions
MarcoWedel

one solution might be:

MarcoWedel_0-1648497516700.png

 

 

table1:
LOAD TransactionDate,
     TransactionID,
     DailyInterest,
     RangeSum(Peek(Interest),Previous(DailyInterest)) as Interest
Inline [
TransactionDate,TransactionID,DailyInterest 
27/03/2022,1115700004,112.83
28/03/2022,1115700004,0.79
29/03/2022,1115700004,0.72
30/03/2022,1115700004,0.71
31/03/2022,1115700004,0.75
01/04/2022,1115700004
];	

 

 

hope this helps

Marco

 

View solution in original post

4 Replies
dmac1971
Creator III
Creator III

Yes you should be able to do this at load using the Peek function :

https://help.qlik.com/en-US/qlikview/May2021/Subsystems/Client/Content/QV_QlikView/Scripting/InterRe... 

MarcoWedel

one solution might be:

MarcoWedel_0-1648497516700.png

 

 

table1:
LOAD TransactionDate,
     TransactionID,
     DailyInterest,
     RangeSum(Peek(Interest),Previous(DailyInterest)) as Interest
Inline [
TransactionDate,TransactionID,DailyInterest 
27/03/2022,1115700004,112.83
28/03/2022,1115700004,0.79
29/03/2022,1115700004,0.72
30/03/2022,1115700004,0.71
31/03/2022,1115700004,0.75
01/04/2022,1115700004
];	

 

 

hope this helps

Marco

 

Kwame
Contributor III
Contributor III
Author

Hi @MarcoWedel  

Just out of curiosity, how would this script "RangeSum(Peek(Interest),Previous(DailyInterest))" be translated into an expression in a chart type, Many thanks.