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

Cumulative Sum on the previous commun Columns

Hello,

i need help to solve this issue , i've tested many codes but still not working on QlikView scripting, I have a data base with Country, Material , Qty

I need to calculate the cumulative Qty for all the previous rows if the key(Country, Material) is equal to the previous one than i do the sum like the example marked in Yellow here bellow row by row.

RaniaMH_0-1646300471197.png

i used Peek but it doesn't work well for my case

Is there any solution to apply this rules in the chart area?

Thank you in advance!

 

Labels (2)
3 Replies
hic
Former Employee
Former Employee

In the Load script you can do a 

If(Country=Peek(Country) and Material=Peek(Material), RangeSum(Qty,Peek(CumulativeQty)), Qty) as CumulativeQty,

Just make sure that you have ordered the rows with an "Order By".

In a chart, you can do something similar using Above() instead of Peek().  

RanMH
Contributor III
Contributor III
Author

Hello,

Yes with the order by it work very well, Thank you!

RanMH
Contributor III
Contributor III
Author

Hello Henric,

I applied the formula but now while doing the test i have duplicated lines whenever i added the CumulativeQty

and i can't use Distinct since i already search recurrences can you help with that ?