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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

How to create a Ranking column in data table based on multiple categories

Hi,

I need to create a Ranking Column based on 2 categories, (Description_Task and Approval_Date) for each NSRNUM as displayed below. I created a calculated column using DAX. But that doesn't give the desired result. Attached one screenshot for one of the NSRNUM. Kindly help.

RANKing Group =
RANKX (
FILTER (
'Table',
'Table'[NSRNUM] = EARLIER ( 'Table'[NSRNUM] )
&& (
'Table'[DESCRIPTION_TASK] < EARLIER ( 'Table'[DESCRIPTION_TASK] )
|| 'Table'[approval_date_fmt] < EARLIER ( 'Table'[approval_date_fmt] )
)
),
'Table'[approval_date_fmt],
,
ASC,
DENSE
)

tanisha_10_0-1719020553612.png

Expectation:

tanisha_10_0-1719021719686.png

 

 

 

 

TIA,

Tanisha

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1719045221289.png

 

RANK function (DAX) - DAX | Microsoft Learn

 

expected result calculated column =
RANK (
    SKIP,
    data,
    ORDERBY ( data[approval_date], ASC ),
    ,
    PARTITIONBY ( data[nsrnum], data[description_task] ),
    MATCHBY ( data[nsrnum], data[description_task], data[approval_date] )
)

 


 

    Microsoft MVP
 

 

   


      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.


   


     
        LinkedInVisit my LinkedIn page
     

   


   


     
        Outlook BookingSchedule a short Teams meeting to discuss your question

     

   


 


View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi, I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1719045221289.png

 

RANK function (DAX) - DAX | Microsoft Learn

 

expected result calculated column =
RANK (
    SKIP,
    data,
    ORDERBY ( data[approval_date], ASC ),
    ,
    PARTITIONBY ( data[nsrnum], data[description_task] ),
    MATCHBY ( data[nsrnum], data[description_task], data[approval_date] )
)

 


 

    Microsoft MVP
 

 

   


      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.


   


     
        LinkedInVisit my LinkedIn page
     

   


   


     
        Outlook BookingSchedule a short Teams meeting to discuss your question

     

   


 


Anonymous
Not applicable

Hi @Jihwan_Kim , This one is perfectly working. Partition by is doing the job here. Thanks you so much 🙂

Anonymous
Not applicable

Hi @Anonymous ,

Based on the description, you seem to have solved the problem.

Please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Wisdom Wu

rajendraongole1
Super User
Super User

Hi @Anonymous - can you try the below calcuated column

 

Ranking_Group =
VAR CombinedValue =
'Table'[DESCRIPTION_TASK] & FORMAT('Table'[approval_date_fmt], "yyyymmdd")
RETURN
RANKX(
FILTER(
'Table',
'Table'[NSRNUM] = EARLIER('Table'[NSRNUM])
),
CombinedValue,
,
ASC,
DENSE
)

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Anonymous
Not applicable

Hi @rajendraongole1 ,

Dont see any ranking with this DAX expressions. Attaching the screenshot below also my sample pbix file. Kindly have a look. Thanks.

tanisha_10_0-1719037735964.png

 

Best Regards,

Tanisha

Hi @Anonymous - Can you please try the solution provided by @Jihwan_Kim 👏

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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