Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
lost_rabbit
Contributor III
Contributor III

Calculate Cumulative percentage without using Above function

I have a dimension that identifies the top N Customers . This is the formula for dimension

=if(Aggr(rank(sum( {<Year={"$(=$(v_Year))"}>} Sales )),Customers )<=$(v_TopN)+1, Customers )


I have a measure that calculates the % contribution for these top customers

=Sum({<Year= {$(=$(v_Year))}>} Sales )/Sum(total {<Year= {$(=$(v_Year))}>} Sales )

 

Now I want to calculate the cumulative % of these Top N (Assume N is 3) customers. I used the above () function but that messes up my sort order. I want it to be sorted like below.

Customer|% contribution| Cumulative %|

A  |   25% |    25%

B  |   65% |   90%

C  |   10% |   100%

The above is my desired result. Please let me know if there's a way to achieve this. Thanks

@sunny_talwar @swuehl @Gysbert_Wassenaar 

Labels (2)
2 Replies
marcus_sommer

It's not above() else the usually there used rowno() which disabled the sorting - it's not a bug else an intended behaviour.

To overcome it is probably quite difficult - never tried it. You could try to replace the rowno() with another calculation - here maybe with the rank().

Another approach might be to include the sorting within the dimension maybe by adding a sorting to the aggr() which is an extra parameter or to create a dual() as dimension whereby your existing dimension-expression defined the string-part and within the numeric-part you set your ordering-logic.

- Marcus

JordyWegman
Partner - Master
Partner - Master

Hi,

I can't try this on my phone, but what if you use a rangesum() approach? You could add up the numbers that way.

Jordy 
Climber 

Work smarter, not harder