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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Cris22
Frequent Visitor

Rank measure base on multiple columns and top 1 , top2 calculation

Good afternoon,

Please, I would appreatiate some help. I have the following:

Sin título.png

 

I would like to get the proper rank for the parameter based on LAP and DRIVER considering the segmentation. I tried with the following measures but none of them are working:

Option 1) RANK = RANKX(ALLSELECTED(Data[LAP];Data[DRIVER]);[PARAMETER];;DESC;Dense)

Option 2) RANK = RANKX(ALLEXCEPT(Data;Data[LAP];Data[DRIVER]);[PARAMETER];;DESC;Dense)

 

With this ranking, I want to get the top1 PARAMETER value (maximum) and top2 PARAMETER value (second maximum)   for each DRIVER.

 

Thank you very much for your help.

 

 

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi, 

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1727631359375.png

 

parameter measure: = 
SUM( data[parameter] )

 

RANK function (DAX) - DAX | Microsoft Learn

 

parameter rank: = 
RANK (
    DENSE,
    ALL ( data[lap], data[driver] ),
    ORDERBY ( [parameter measure:], DESC ),
    ,
    PARTITIONBY ( data[driver] )
)

 

top 2 by driver: = 
IF ( [parameter rank:] <= 2, [parameter measure:] )

 

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hello, Thank you Jihwan_Kim for your answer.

 

I tried with the ranking you told me, but I still has problems. I have complete the phbix file you did to show you my problem.Captura de pantalla 2024-09-30 072245.png

 I am trying to attached the phbix that I completed, but I can't.

 

I think, there is a problem on the code because it has to take into account the segmentation of the year (2022,2023), track (test, test 1,..) and session (example:R1,R2,..).Captura de pantalla 2024-09-30 073922.png

 Thank you

Hi,

please share the link of your sample pbix file (onedrive link, dropbox link, or others), and then I can try to look into it.

Thank you.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hello, I am not sure if it can be openend by you in here: 

Cris22v2.pbix

 

I share it with you by email as well.

Thank you

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.