Uzzy
Uzzy

Reputation: 489

Return TOP 5 values in column by category

I'm looking for good solution to be able to present on a table visual in Power BI TOP 5 highest values out of column X in table, grouped by User name in column Y of the same table.

So for each distinct user in column Y I need to show top 5 values in column X in descending order.

Upvotes: 0

Views: 1196

Answers (1)

CR7SMS
CR7SMS

Reputation: 2584

You can get the Top 5 details by using the RANKX function:

Rank = RANKX(CALCULATETABLE(Table,ALLEXCEPT(Table,Table[Column Y])),Table[Column X],,DESC,DENSE)

The above calculation will give you the dense rank. If you want the normal ranking use "skip" instead of "dense". Once the rank is calculated, you can filter the rank value for <=5 and you should be able to get the desired output.

Upvotes: 1

Related Questions