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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
alicia_mtz
Helper II
Helper II

Measure top X performer

Hi all!

 

I'm trying to get the top X performer without having to display all the previous ones using TopN.

 

For instance, if I click a region in a map (or click a region in a normal slicer) I want to see the number 2 sales performer.

 

I've read this topic about the same question and I adapted the code there to my case. I've made it work for one result (name of the sales agent) but not quite for showing their profit. I'm still learning DAX so I still struggle sometimes...

 

How to get the second top performer 

 

I have a table called "Sales Agents" and another one called "Sales", so these are the 2 measures I have:

 

Agents ranked = RANKX(ALLSELECTED('Sales Agents'[Sales Agent Name]), CALCULATE(SUM('Sales'[Profit])))

 

And the one showing in this case Top 2 perfomer:

 

Agents filtered by rank = CONCATENATEX(FILTER(ADDCOLUMNS(SUMMARIZE(VALUES('Sales Agents'[Sales Agent Name]), 'Sales Agents'[Sales Agent Name]), "rk" , [Agents ranked])
, [rk] = 2), [Sales Agent Name])

 

With this I get the Name of the sales agent correctly, which is fine.

 

Now I'm trying to adapt this to show their profit, and I get the correct result but in text format. Is there a way to adapt the code to get the result as a number?

 

The first measure I left it the same. The second measure I adapted it like this:

 

Agents filtered by rank =
CONCATENATEX(FILTER(ADDCOLUMNS(SUMMARIZE(VALUES('Sales Agents'[Sales Agent Name]), 'Sales Agents'[Sales Agent Name]), "rk" , [Agents ranked]), [rk] = 2), [Total Profit])

 

I've tried to remove the concatenatex part as it's a string function but I'm getting an error and the measure doesn't get created.

 

Can you help me please?

 

Thank you very much in advance! 😊

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@alicia_mtz , Try the new index function

Power BI Index function: Top/Bottom Performer by name and value- https://youtu.be/HPhzzCwe10U

 

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@alicia_mtz , Try the new index function

Power BI Index function: Top/Bottom Performer by name and value- https://youtu.be/HPhzzCwe10U

 

 

Hi @amitchandak 

 

I'm sorry for my late reply, but I couldn't actually tested until today! Thank you very much for pointing out the video! I managed to create the proper measure thanks to it! 🙂

 

Just in case is helpful, I also followed this video from Curbal: DAX Fridays #219: INDEX function 

 

Thanks again! 😊

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.