Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
kgruneich
Contributor
Contributor

Sum of Volume of the Top 10 by Percentage Change

I have a chart were it lists the top 10 locations by Percentage change in production. This works just fine. The chart is sorted by top 10 and uses the below expression for percentage changed. 

 

if(Sum( { $< [ProductionYear] = {'$(=GetFieldSelections([ProductionYear])-1)'} > } [actual_tons] )=0,
	1 
,
	(Sum( { $< [ProductionYear] = {'$(=GetFieldSelections([ProductionYear]))'} > } [actual_tons] )
	-Sum( { $< [ProductionYear] = {'$(=GetFieldSelections([ProductionYear])-1)'}> } [actual_tons] )
	)/ Sum( { $< [ProductionYear] = {'$(=GetFieldSelections([ProductionYear])-1)'} > } [actual_tons] )
)

 

where I'm having trouble is getting the total tons of only the top ten based on the percentage changed. The expression works but the total is not accurate. varDifferenceInProductionVolume is the above expression.

 

//Current Version
sum({$< [ProductionYear] = {"$(=GetFieldSelections([ProductionYear]))"} , LocationID={"=rank($(varDifferenceInProductionVolume),4)<=10"} >} [actual_tons])

//Refined !!Not Accurate!!
//Sum( { < [ProductionYear] = {"$(=GetFieldSelections([ProductionYear]))"} > } [actual_tons] )

//simple test !!Not Acurate!!
//sum({<LocationID={"=rank($(varDifferenceInProductionVolume),4)<=10"} >} [actual_tons])

//Code found on the Community
//sum({<CLIENTFIELD={"=rank(sum(REVENUEFIELD),4)<=10"} >} REVENUEFIELD)

 

 

simply put how do I get the total tons from the top 10 plants by percentage changed.

In the attached image the total ton should be  3.18m not 1.07m in the Sum Top 10 KPI , however if I select the all ten locations the total is correct.

Thanks for the help in advance

Labels (4)
2 Replies
morgankejerhag
Partner - Creator III
Partner - Creator III

Maybe you can use the rank() function to calculate the top 10?

Morgan Kejerhag
Senior Business Intelligence Consultant
Drake Analytics
http://www.drakeanalytics.se

kgruneich
Contributor
Contributor
Author

I am using the rank function inside the set analysis section.