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: 
Not applicable

Loop through chart(straight table) and perform calculations

Hi Guys,

I have a kind of unusual task for me. I need to loop through chart values and asign records to specific flag according to calculation results. Here is my chart that i need to make calculations:

profit.png

What i need to do now is to sum the entire colum Profit and dive it by 3. This is ok i can aproach it.

when io sum and divide by 3 i get 1 066 491/3=355 497.

What i have to doo now is to start looping from the first record(records are sorted by largest to smallest) and start summing until the sum of summed records is >= to 355 497(the number i got when divided the whole sum).

So in this case Salesman1, Salesman2, Salesman 3 fulfill my condition and i have to mark them as a flag A.

Then when i have Found A records already i need to continue where i stopped. I will start summing from Salesman4,salesman5,salesman6,salesman7 and again when i reach 355 497 i stop and mark those records as a flag B

all the remaining records below last record with B i mark as a C.

This is like a simple for or while loop but how to write it in qlikview? Can i approach it via expressions or have to do it in load script. If you guys could help me i would save my next days:)

Thanks

10 Replies
Not applicable
Author

I think i can't do it in the backend because in the front end i calculate Sum(profit) and the Sum(profit) changes dynamicaly if i select some other drill down values like date, City o some kind of products catagery.

If i calculate the values in the back end - it will not change.