Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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!
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous 

     

    Have a try

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

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

     

    Have a try

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

     

    • Anonymous's avatar
      Anonymous
      Not applicable

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