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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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