Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to do a few things in a KPI:
This expression works for ranking the commodity by the amount that is flagged as "Aged" - it is the definition of the variable "vRank":
rank(Sum({<Cooler={'SAL','YUM'},Flag_Aged={1}>}Quantity))
The expression the KPI is: Sum({<vRank={1},Cooler={'SAL','YUM'},Flag_Aged={1}>} Quantity)
However, the result is not being limited to the Commodity that is ranked as 1.
Please advise. Thank you.
Screenshot shows KPI result and table of top 10 commodities, using the Fixed Number limitation on Commodity. The expression for the Quantity Aged field is: Sum({<Flag_Aged={1},Cooler={'SAL','YUM'}>}Quantity). In this example, I'm trying to get the KPI to show the Quantity Aged for commodity ROM since it is ranked #1.
My mistake, that's all I missed =
sum({<Commodity={"=rank(Sum({<Flag_Aged={1}>}Quantity))=1"}>}Quantity)
Hi,
Maybe this, inserting the rank in your set analysis:
sum({<Commodity={"rank(Sum({<Cooler={'SAL','YUM'},Flag_Aged={1}>}Quantity))=1"}>}Quantity)
- Regards, Matheus
Hi Matheus,
I'm getting a 0 as the result of that expression. I updated the data load script to exclude various Coolers and Commodities, so the set expression can now be simplified to
sum({<Commodity={"rank(Sum({<Flag_Aged={1}>}Quantity))=1"}>}Quantity).
I also tried
Sum({<Commodity={"rank(Sum({<Flag_Aged={1}>}Quantity))=1"},Flag_Aged={1}>}Quantity)
but that results in a 0 value as well.
My mistake, that's all I missed =
sum({<Commodity={"=rank(Sum({<Flag_Aged={1}>}Quantity))=1"}>}Quantity)
Perfect. Thank you.
Hi
Not Sure but you can't call a variable (vRank) in a set analysis : it must be a dimension
So try
IF(
rank(Sum({<Cooler={'SAL','YUM'},Flag_Aged={1}>}Quantity)) = 1 ,
Sum({<Cooler={'SAL','YUM'},Flag_Aged={1}>}Quantity), 0
)
and may be to get the commodities :
firstsortedvalue (
commodities ,
IF(
rank(Sum({<Cooler={'SAL','YUM'},Flag_Aged={1}>}Quantity)) = 1 ,
Sum({<Cooler={'SAL','YUM'},Flag_Aged={1}>}Quantity), 0
)
)
Oh, almost forgot. How do I get the label of the KPI to show the Commodity?
Hi Bruno,
I tried your expression using FirstSortedValue, but it's throwing an error about a nested aggregation. I tried searching for that error and found several posts in Qlik Community with no solution. Not sure what to do at this point.
for the label, see like this:
=only({<Commodity= {"=Rank(sum({<Flag_Aged={1}>}Quantity))=1"}>} Commodity)
Hi Matheus,
That worked great. Thank you very much.