Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jansen28
Contributor III
Contributor III

How to remove duplicates in FirstSortedValue?

Hi, I need to find which [Sales Person] has performed well in a country? Here is my input table

CountryStateCitySales Personsale
ArgentinaBuenos AiresAyacuchoPamela1200
AustraliaNew South WalesAvalonAnke3600
AustraliaNew South WalesLindfiledJacob3600
AustriaViennaInner CityCorina3600
AustriaViennaMid CityCorine5000

My output in qlikview:

Country Largest Sales By SaleRep FirstSortedValue(SalesPerson,-aggr(sum(Sale),Country,SalesPerson))
5000 Mike
Argentia1200Jan
Australia3600
Austria5000Mike

So there is null value in my 2nd row. Hence how do I remove duplicate or how should I bring my top Performer with repeated value?

Any help appreciated?

2 Replies
Not applicable

As far as I know, first sorted value returns a blank/null when more than value has the same weight. So here two names could end up having the same sales and hence it is not able to return a value. You can pick one by changing the formula to FirstSortedValue(distinct SalesPerson,-aggr(sum(Sale),Country,SalesPerson))

jansen28
Contributor III
Contributor III
Author

Thanks for the reply Chander:)