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
axy5092
Frequent Visitor

Ranking rows based multiple columns with a specific order

Hi, 

 

I need to rank my data based on updatedDate(Sort Asc) and Status but only increment for specific status.  For most part i am able to use rankx and get an order but need help on modifying this to ensure it increments only for certain status. 

 

I.e. For each ID, Status "ND" will always be version 1 (Updated date helps in ensuring this) and from there on only when status is "NDV" the version needs to be incremented. This change of status between "ND", intermediate status (C, E) and "NDV" can happen any number of times. ND will occur only once. 

 

My current DAX for column "version" below 

Version = RANKX( FILTER('TestVersion', 'TestVersion'[Id]=EARLIER('TestVersion'[Id])),'Test Version'[UpdatedDate] && 'Test Version'[Status]= "NDV",,ASC,Dense)

 

Output needed: "VersionNeeded" column below 

 

Sample data and out put needed 

IdStatusUpdatedDateUpdatedDateOrderVersionVersionNeeded
1ND1-Jan-21111
1E1-Feb-21211
1NDV1-Mar-21322
1C1-Apr-21412
1NDV1-May-21523
1E1-Jun-21613
1NDV1-Jul-21724
1E1-Aug-21814
1NDV1-Sep-21925
2ND1-Jan-21111
2E1-Feb-21211
2NDV1-Mar-21322
2E1-Apr-21412
2NDV1-May-21523
2C1-Jun-21613
2NDV1-Jul-21724
 
Thanks in advance for any help!
1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @axy5092 

 

Have a try

Vera_33_0-1644024540521.png

Version1 = 
RANKX( FILTER('TestVersion', 'TestVersion'[Status]= "NDV"),[UpdatedDateOrder],[UpdatedDateOrder]+1,ASC,Dense)

 

View solution in original post

2 REPLIES 2
Vera_33
Resident Rockstar
Resident Rockstar

Hi @axy5092 

 

Have a try

Vera_33_0-1644024540521.png

Version1 = 
RANKX( FILTER('TestVersion', 'TestVersion'[Status]= "NDV"),[UpdatedDateOrder],[UpdatedDateOrder]+1,ASC,Dense)

 

Great, that worked perfect. Thanks a lot, appreciate the fast response 

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.