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

Top N % to total

I'm looking to display the top 10 location's $ percent to total.  I have a chart to display the top 10 using a dimension expression of

=if(aggr(Rank(Sum(Dollar_Demand_Net)),Location)<=10,Location)

Suppressing When Value is Null

and an expression of Sum(Dollar_Demand_Net)

However, I need to see that total value's percent to the total of ALL locations.  I realize I can't get this in the same chart but hope I can get it in a text object.

The total of all locations is easy, but how do I calculate the top 10 locations in a text, object single's expression? 

p.s.

This didn't work as an expression

Sum({<Location={$(=if(aggr(Rank(Sum(Dollar_Demand_Net)),Location)<=10,Location))}>} Dollar_Demand_Net)

Thoughts...

13 Replies
Jason_Michaelides
Luminary Alumni
Luminary Alumni

Brilliant 🙂 Must be right!

Anonymous
Not applicable
Author

Yup, Brilliant! Thank you swuehl!  I'm still surprised you don't need to aggr rank by Location but you don't.  Your solution works great.

swuehl
MVP
MVP

No, you don't need to explicitely aggregate over the field on which you want to perform an advanced search to filter sets.

Please compare with the example from the Help file:

sum( {$<Customer = {“=Sum({1<Year = {2007}>} Sales ) > 1000000”}>} Sales )

Same here, Sales is aggregated per Customer, hence the field name of the element_set is defining the scope of the advanced search aggregation functions.

Regards,

Stefan

Jagveer
Contributor III
Contributor III

HI,

I have been searching for something similar but the expression that i have is aggregated based on year so when i use your solution it says nested aggregation not allowed. Could you please help.

This is my top 10 data based on YoY change

The YoY change is calculated column

sum({<Year={2020}>} [Revenue CAD_QTD])- sum({<Year={2019}>} [Revenue CAD_QTD])

Account20192020YoY Change% Change
 $1,898.78$2,550.76$651.9834.34%
C1$710.07$874.23$164.1523.12%
C5$70.20$200.74$130.53185.93%
C4$261.18$380.68$119.5045.75%
C3$306.82$410.19$103.3633.69%
C2$488.39$556.05$67.6613.85%
C9$25.73$68.06$42.33164.49%
C23$5.05$15.00$9.94196.86%
C25$4.15$10.25$6.10147.06%
C22$11.05$15.40$4.3539.39%
C19$16.12$20.17$4.0525.12%