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

Ranking based on multiple criteria

Hi All, 

 

I have the following data: 

NameStatusDateTime
A12020/01/05 17:59:57
A12020/01/05 17:59:59
A22020/01/05 17:59:35
B12020/01/05 17:59:54
B12020/01/05 17:59:55

 

I need to rank my table based on status and date. 

I want to rank my table based on status = 1 with Desc datetime. 

So my O/P should look like as follows: 

 

NameStatusDateRank
A12020/01/05 17:59:591
A12020/01/05 17:59:572
B12020/01/05 17:59:553
B12020/01/05 17:59:544

 

I have tried the query which can rank based on the date (Desc) but as soon as I am clubbing it with filter all the records are getting ranked as "1". 

 

I can not add a column to the dataset no I need to restrict myself to the measure. 

 

Thanks

7 REPLIES 7
v-xicai
Community Support
Community Support

Hi  @Anonymous  ,

 

Does that make sense? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

 

Best regards

Amy

v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create rank using Column or measure like DAX below.

 

Column1= RANKX(FILTER(ALLSELECTED(Table1),Table1[Name]=EARLIER(Table1[Name])&&Table1[Status]=1),Table1[Date],,DESC, Dense)
 
Measure1= RANKX(FILTER(ALLSELECTED(Table1),Table1[Name]=MAX(Table1[Name])&&Table1[Status]=1),MAX(Table1[Date]),,DESC, Dense)

 

You can go through the link https://docs.microsoft.com/zh-cn/dax/rankx-function-dax to learn more about the RANKX .

 

Best Regards,

Amy

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

parry2k
Super User
Super User

@Anonymous it is very well explained in this post, just follow the instructions on how to rank category and sub category which is the use case for you.

 

Would appreciate Kudos 🙂 if my solution helped.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k,amitchandak: I tried that solution provided by and my query looks following: 

Ranking by Sub Category =
    RANKX (
        FILTER(
            ALL(
               --DateTime Column
                WorkItemCompltd[operationutcdttm],
               -- Status
                WorkItemCompltd[workitemstatus]
                ),
            --datetime column (Filter1)
            WorkItemCompltd[operationutcdttm] = MAX(WorkItemCompltd[operationutcdttm])
            ),
            ---Filter 2 (status)
            CALCULATE(MAX(WorkItemCompltd[workitemstatus]))
            )
 
This ranks everything as 1. Please correct me if i am wrong somewhere.

@Anonymous try this. seems like you didn't try to read the post but just followed the dax, try to understand the concept.

 

RANKX (
        FILTER(
            ALL(
               --DateTime Column
                WorkItemCompltd[Name],
               -- Status
                WorkItemCompltd[workitemstatus]
                ),
            --datetime column (Filter1)
            WorkItemCompltd[workitemstatus] = MAX(WorkItemCompltd[workitemstatus])
            ),
            ---Filter 2 (status)
            CALCULATE(MAX(WorkItemCompltd[operationutcdttm]))
            )

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k : With the last solution it ranks everything as "1". 

I went through the article again and now understood to get all the row we have two columns as input to ALL

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.