Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
maya_yurika
Contributor
Contributor

sum of current and previous rows in qlikview

Hi,

Can you help me with a solution for the following problem?

I have the following fields (ID, date, posting_date and Value). I need to calculate the field TotalSum inside the script (the functions above/below etc are not working) as the sum from current and previous rows. I have an example below for better understanding:

ID date posting_date Value TotalSum
46 7/29/2023 2023-07-19                       2,000  
46 7/29/2023 2023-07-20                         200            2,200
46 7/29/2023 2023-07-21                         100            2,300
46 7/29/2023 2023-07-23                         500            2,800
46 7/29/2023 2023-07-24                         800            3,600
46 7/29/2023 2023-07-25                         300            3,900
46 7/29/2023 2023-07-26                         100            4,000
46 7/29/2023 2023-07-27                         500            4,500
46 7/29/2023 2023-07-28                         600            5,100
46 7/29/2023 2023-07-31                         100            5,200

 

Thank you

Labels (1)
2 Replies
ali_hijazi
Partner - Master II
Partner - Master II

Hello @maya_yurika 
no need to do anything in the script


add a table
add for example the posting date as a dimension

use the either of the following expressions: (note in this example the total sum will be the same even if you select a posting date so add other dimensions used in the table so that result stays the same on any selection made on the dimensions used in the table)
of course do not add the value as a dimension
also in the Add Ons -> data handling uncheck the include zero values


=RangeSum(
Sum(Value),
Above(Sum({<posting_date>}[Value]))
)
*
Avg(1)

 

or 

 

=RangeSum(

Above(
Sum({<posting_date>}[Value])
,0,RowNo())
) *
Avg(1)

 

I can walk on water when it freezes
anat
Master
Master