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

Rank by User Id, Date, with Filter

Hi everyone, 

 

I am looking to rank my Orders based on the USER ID (repeats) and DATE, but only for completed orders. 

 

I have this DAX for a calculated column, but as you can see, it isn't working correctly for some reason.

 

DAX: 

 

 

 

Rank Column = 
VAR d = Orders[Completed At]
VAR c = Orders[User Id]
RETURN
    CALCULATE (
        RANK.EQ ( d, Orders[Completed At], ASC ),
    FILTER ( ALL ( Orders ), Orders[Status]="Completed"),  Orders[User Id] = c )

 

 

 

Results: 

User IdCompleted At Status Rank Column
100282/21/21 COMPLETED 1
100282/23/21 COMPLETED 2
100289/10/21 COMPLETED 3
101607/12/21 CANCELED  
101608/23/21 COMPLETED 1
1016010/5/21 COMPLETED 4
1016011/22/21 COMPLETED 5

 

For some reason, the ranking didn't work for the USER ID "10160"

 

Does it have to do with my filtering for [Status]=Completed ? 

 

Thank you for the help!!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

Rank CC =
VAR currentid = Orders[User Id]
VAR newtable =
FILTER ( Orders, Orders[User Id] = currentid && Orders[Status] = "COMPLETED" )
RETURN
IF (
Orders[Status] = "COMPLETED",
RANKX ( newtable, Orders[Completed At],, ASC )
)



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

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Picture1.png

 

Rank CC =
VAR currentid = Orders[User Id]
VAR newtable =
FILTER ( Orders, Orders[User Id] = currentid && Orders[Status] = "COMPLETED" )
RETURN
IF (
Orders[Status] = "COMPLETED",
RANKX ( newtable, Orders[Completed At],, ASC )
)



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



How can you get this to work if you have a tie with the dates. I.e the same dates under the same id and you need it to give a different rank based on the row order. I don't have access to the query editor for this table.

@Jihwan_Kim thank you so much

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.