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
Anonymous
Not applicable

Ranking based on date and status

Hi All, 

 

I have data that looks like 

NameStatusdatetime(UTC)
A12020/01/05 17:59:57
A22020/01/05 17:59:52
A22020/01/05 17:59:51
A32020/01/05 17:59:50
B22020/01/05 17:59:53
B22020/01/05 17:59:54

 

I Need to rank them based on status and datetime (for example status as 2). 

My output should be : 

 

B22020/01/05 17:59:541
B22020/01/05 17:59:532
A22020/01/05 17:59:523
A22020/01/05 17:59:514

 

I can not add columns so I need to archive this using measure, I have tried many measures but none of them has succeeded. 

 

Please help!

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

Create a measure using dax below:

Rank = 
RANKX (
    FILTER (
        ALL ( 'Table' ),
        COUNTROWS ( FILTER ( 'Table', 'Table'[Status] = EARLIER ( 'Table'[Status] ) ) )
    ),
    CALCULATE ( ( SUM ( 'Table'[datetime(UTC)] ) ) ),
    ,
    DESC,
    DENSE
)

Capture.PNG 

 

Community Support Team _ Jimmy Tao

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

View solution in original post

5 REPLIES 5
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

Create a measure using dax below:

Rank = 
RANKX (
    FILTER (
        ALL ( 'Table' ),
        COUNTROWS ( FILTER ( 'Table', 'Table'[Status] = EARLIER ( 'Table'[Status] ) ) )
    ),
    CALCULATE ( ( SUM ( 'Table'[datetime(UTC)] ) ) ),
    ,
    DESC,
    DENSE
)

Capture.PNG 

 

Community Support Team _ Jimmy Tao

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

Hi @v-yuta-msft 

 

I have tried your solution and it is working perfectly fine. However I am having issues understanding it. Can you explain the logic behind Filter part.

 

Thanks

Ankit Jain

@AnkitBI ,

 

I would suggest you read blog below:

https://javierguillen.wordpress.com/2012/02/06/can-earlier-be-used-in-dax-measures/

 

Community Support Team _ Jimmy Tao

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

Hi @v-yuta-msft 

 

Thanks for the link. I actually figured out the nested filter concept. What I was struggling with was the use of CountRows as I thought second parameter in "Filter" should be a condition that returns a boolean value but it seems even 1 is an expectable value.

 

Again thanks for this new learning 🙂

 

Thanks

Ankit Jain

AnkitBI
Solution Sage
Solution Sage

Hi @Anonymous 

Can you try below.

RankValue =
RANKX (
    ALLEXCEPT ( 'Table', 'Table'[Status] ),
    CALCULATE ( MAX ( 'Table'[datetime(UTC)] ) )
)

Thanks
Ankit Jain
Do Mark it as solution if the response resolved your problem. Do Kudo the response if it seems good and helpful.

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.