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

Announcements
April 13–15 - Dare to Unleash a New Professional You at Qlik Connect 2026: Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
kkkumar82
Specialist III
Specialist III

Top N Analysis issue

All,

Attaching a qvw file where I want to have two things

1.  One in a text box

2. Another in a pivot table.

Ist requirement:

Want to see top 5 salesman along with their sales

I was able to get top 5 Salesman but not their sales

2nd requirement

Have a pivot table ProductID, SalesmanID

In the pivot table I am showing top 5 SalesmanID for each productID(got this)

also want to show the top Performers in a productID along with his sales in the pivot table

Kiran Kumar

1 Solution

Accepted Solutions
sunny_talwar

2) Two expression for your 2nd requirement

Top Performer - > FirstSortedValue(TOTAL <[Product ID]> Salesman, -Aggr(Sum(Sales),[Product ID],[Salesman ID]))

Top Performer's Sales -> Max(TOTAL <[Product ID]> Aggr(Sum(Sales), [Product ID], [Salesman ID]))

Capture.PNG

View solution in original post

6 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this using variable

Regards,

jagan.

kkkumar82
Specialist III
Specialist III
Author

Hi Jagan,

Sorry I didn't find the solutions , did I miss anything.

Attaching some pics for further clarity.

Text Box1.png

I was able to get the above text box but was not able to get the Sales of the persons after them for a selected product.

Top Performers.png

In the above for Top Performer I want Charles ... name becuase he is the top sales and in the next column the sales of Charles..

Hope I am clear this time.

Thanks

Kiran Kumar

sunny_talwar

1) Expression for 1st requirement

=If(GetSelectedCount([Product ID]) = 0, 'Select a ProductID', Concat(Distinct If(Aggr(Rank(Sum(Sales)), [Product ID],[Salesman ID]) <=5, [Salesman ID] & '-' & Aggr(Sum(Sales), [Product ID], [Salesman ID])), Chr(13)))


Capture.PNG

sunny_talwar

2) Two expression for your 2nd requirement

Top Performer - > FirstSortedValue(TOTAL <[Product ID]> Salesman, -Aggr(Sum(Sales),[Product ID],[Salesman ID]))

Top Performer's Sales -> Max(TOTAL <[Product ID]> Aggr(Sum(Sales), [Product ID], [Salesman ID]))

Capture.PNG

kkkumar82
Specialist III
Specialist III
Author

Thanks sunny it solved my problem just like that.  regards Kiran Kumar