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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.