Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
rjennings
Regular Visitor

Output calculated table of top 3 employees for each metric

Hi everyone, so this is a really tricky problem that I've been stuck on all week... I have a dataset of orders and the employees who processed them where we calculate KPIs. I would like to make a report of "Top 3 Employees by Metric" where I have bar charts with the number 1, 2, and 3 employees for a given metric (think olympic podium style) on the x-axis, and their values as 1 (for the number 1 employee), 2 (for number 2), and 3 (for number 3). I'll just stick with three metrics for simplicity's sake, here is the starting data table:

 

 

Order NumberEmployeeItem CountCancelled CountReturn Count
1Joe321
2Bob502
3Sue211

 

And here is the output table I would like to achieve:

 

RankItem CountCancelled CountReturn Count
1BobBobJoe
2JoeSueSue
3SueJoe

Bob

 

As you can tell there are situations where I need to break ties (e.g. in the return count metric, Joe and Sue are tied) and I would like to break the ties using the total Item Count column. I've tried using the RANKX and TOPN functions with no luck, though I'm probably doing something wrong. When I can get them to rank at all, many times they are all rank 1, or sometimes the ranks are clearly incorrect (like saying 4 is greater than 10). In addition this output needs to react to changing slicers on the page (e.g. someone choosing a new store with different employees, or a different date range). Any ideas? I need to get a draft of this out by tomorrow and have kinda exhausted all the other options. Thanks!

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi, @rjennings 

Please check the below picture and the sample pbix file's link down below.

 

Picture2.png

 

Item Count Rank Measure =
VAR selectrank =
SELECTEDVALUE ( Ranking[Rank] )
VAR newtable =
FILTER (
Data,
CALCULATE ( SUM ( Data[Item Count] ) )
= MINX (
TOPN ( selectrank, Data, CALCULATE ( SUM ( Data[Item Count] ) ), DESC ),
CALCULATE ( SUM ( Data[Item Count] ) )
)
)
RETURN
IF( ISFILTERED(Ranking[Rank]),
MAXX ( newtable, Data[Employee] )
)
 
 
Cancelled Count Rank Measure =
VAR selectrank =
SELECTEDVALUE ( Ranking[Rank] )
VAR newtable =
FILTER (
Data,
CALCULATE ( SUM ( Data[Cancelled Count] ) )
= MAXX (
TOPN (
selectrank,
Data,
CALCULATE ( SUM ( Data[Cancelled Count] ) ), ASC
),
CALCULATE ( SUM ( Data[Cancelled Count] ) )
)
)
RETURN
IF( ISFILTERED(Ranking[Rank]),
MAXX ( newtable, Data[Employee] )
)
 
 
Return Count Rank Measure =
VAR selectrank =
SELECTEDVALUE ( Ranking[Rank] )
VAR newtable =
FILTER (
Data,
100 * CALCULATE ( SUM ( Data[Return Count] ) )
+ 1 / CALCULATE ( SUM ( Data[Item Count] ) )
= MAXX (
TOPN (
selectrank,
Data,
100 * CALCULATE ( SUM ( Data[Return Count] ) )
+ 1 / CALCULATE ( SUM ( Data[Item Count] ) ), ASC
),
100 * CALCULATE ( SUM ( Data[Return Count] ) )
+ 1 / CALCULATE ( SUM ( Data[Item Count] ) )
)
)
RETURN
IF( ISFILTERED(Ranking[Rank]),
MAXX ( newtable, Data[Employee] )
)
 
 
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.