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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Jeanxyz
Impactful Individual
Impactful Individual

DAX rank in column

I have a table with multiple Issue_Keys, each issue_Key has multipel status records. I would like ot rank the status records based on [Created] field per Issue_Key. [Ranking expected] is what I expect:

 

The DAX I wrote causes a dependency circular error: 

Ranking =
rankx(filter(all('Fact_Status Log'),'Fact_Status Log'[ISSUE_KEY]=earlier('Fact_Status Log'[ISSUE_KEY])),
calculate(max('Fact_Status Log'[CREATED])))

 

ISSUE_KEYFIELDCREATEDOLD_VALUE_FORMATTEDRanking expected
xxx-202status6/10/2024 3:47New1
xxx-202status6/11/2024 4:46investigating2
xxx-202status6/11/2024 4:56Waiting for customer3
xxx-202status8/21/2024 4:44investigating4
xxx-202status8/22/2024 2:56Waiting for customer5
xxx-202status8/22/2024 9:06 6
xxx-202status8/23/2024 1:17Waiting for customer7
xxx-203status6/10/2024 3:47New1
xxx-203status6/11/2024 4:46investigating2
xxx-203status6/11/2024 4:56Waiting for customer3
xxx-203status8/21/2024 4:44investigating4
xxx-203status8/22/2024 2:56Waiting for customer5
xxx-203status8/22/2024 9:06Mediagenix investigating6
xxx-203status8/23/2024 1:17Waiting for customer7
1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@Jeanxyz , Use below DAX

 

DAX
Ranking =
VAR CurrentIssueKey = 'Fact_Status Log'[ISSUE_KEY]
VAR CurrentCreated = 'Fact_Status Log'[CREATED]
RETURN
CALCULATE(
COUNTROWS(
FILTER(
'Fact_Status Log',
'Fact_Status Log'[ISSUE_KEY] = CurrentIssueKey &&
'Fact_Status Log'[CREATED] <= CurrentCreated
)
),
ALLEXCEPT('Fact_Status Log', 'Fact_Status Log'[ISSUE_KEY])
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

2 REPLIES 2
bhanu_gautam
Super User
Super User

@Jeanxyz , Use below DAX

 

DAX
Ranking =
VAR CurrentIssueKey = 'Fact_Status Log'[ISSUE_KEY]
VAR CurrentCreated = 'Fact_Status Log'[CREATED]
RETURN
CALCULATE(
COUNTROWS(
FILTER(
'Fact_Status Log',
'Fact_Status Log'[ISSUE_KEY] = CurrentIssueKey &&
'Fact_Status Log'[CREATED] <= CurrentCreated
)
),
ALLEXCEPT('Fact_Status Log', 'Fact_Status Log'[ISSUE_KEY])
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks a lot, @bhanu_gautam . It works like a charm. 

 

I slightly changed the measure, using all() instead of allexcept(), it also works.

Ranking =
VAR CurrentIssueKey = 'Fact_Status Log'[ISSUE_KEY]
VAR CurrentCreated = 'Fact_Status Log'[CREATED]
RETURN
CALCULATE(
COUNTROWS(
FILTER(all('Fact_Status Log'),
'Fact_Status Log'[ISSUE_KEY] = CurrentIssueKey &&
'Fact_Status Log'[CREATED] <= CurrentCreated
)
))

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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