Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Jberry
Contributor
Contributor

Highest Sales Store KPI

Hi, 

I'm using the below code to try and show the highest sales store in my KPI. Can anyone suggest why it returns a dash instead of a Store Name please?

if(FirstSortedValue([Retailer Name],-Aggr(Sum([Sales Value Gross]),[Retailer Name]))=[Retailer Name],
([Retailer Name]),
null())

I used this code because I successfully got a KPI to show the busiest day using the following code:

if(FirstSortedValue([Day Of Week],-Aggr(Sum([Sales Value Gross]),[Day Of Week]))=6,
subfield(LongDayNames,';',0),
subfield(LongDayNames,';',(FirstSortedValue([Day Of Week],-Aggr(Sum([Sales Value Gross]),[Day Of Week])))+1))

Thanks,

Jen

Labels (2)
1 Solution

Accepted Solutions
Mathumitha
Partner - Contributor III
Partner - Contributor III

Is it possible to share the sample data? @Jberry 

View solution in original post

4 Replies
Mathumitha
Partner - Contributor III
Partner - Contributor III

Hi @Jberry ,

 

You'll be able to get the desired output without using the if condition.

Like this,

FirstSortedValue([Retailer Name],-Aggr(Sum([Sales Value Gross]),[Retailer Name]))

If you need to use if  condition, then you do as mentioned below,

if(len(FirstSortedValue([Retailer Name],-Aggr(Sum([Sales Value Gross]),[Retailer Name])))>0,
FirstSortedValue([Retailer Name],-Aggr(Sum([Sales Value Gross]),[Retailer Name])),
null())

Jberry
Contributor
Contributor
Author

Thank-you for this @Mathumitha - I have applied this expression and it works perfectly!

I am having a similar issue trying to find the store name with the highest wastage (formula below)? I applied the same logic as above only I changed the Sales Value Gross with 'Wastage Cost Value'. The expression appears to be ok in but it isn't giving me the store name:

if(len(FirstSortedValue([Retailer Name],-Aggr(Sum([Wastage Cost Value]),[Retailer Name])))>0,
FirstSortedValue([Retailer Name],-Aggr(Sum([Wastage Cost Value]),[Retailer Name])),
null()) 

I also tried this formula but it is just the same:

FirstSortedValue([Retailer Name],-Aggr(Sum([Wastage Cost Value]),[Retailer Name]))

Mathumitha
Partner - Contributor III
Partner - Contributor III

Is it possible to share the sample data? @Jberry 

Jberry
Contributor
Contributor
Author

@Mathumitha Thank you very much for your help with that! Got sorted!