cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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 )
)

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.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
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 )
)

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.


Go to My LinkedIn Page


@Jihwan_Kim thank you so much

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors