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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
ChrisW764
Regular Visitor

DAX to return the date a row Entered a given Status

Hi peeps,

 

Really hoping someone can help me with this as it's been doing my  head in for ages!!

I have a table called "Status Change" with columns as below.  I have provided sample values filtered for a single Acc_ProjectChangeRequest__c.

Acc_ProjectChangeRequest__cCreatedDateAcc_PreviousProjectChangeRequestStatus__cAcc_NewProjectChangeRequestStatus__cRankByDate
a0GP3000002gp9vMAA01/12/2023 18:05Submitted to Approver2In Review with CompanyName8
a0GP3000002gp9vMAA01/12/2023 18:05In Review with CompanyNameSubmitted to Approver27
a0GP3000002gp9vMAA01/12/2023 15:04Submitted to CompanyNameSubmitted to Approver26
a0GP3000002gp9vMAA01/12/2023 14:31Queried by CompanyNameSubmitted to CompanyName5
a0GP3000002gp9vMAA01/12/2023 13:05Submitted to CompanyNameQueried by CompanyName4
a0GP3000002gp9vMAA30/11/2023 07:44Submitted for Approver1Submitted to CompanyName3
a0GP3000002gp9vMAA29/11/2023 15:01DraftSubmitted to Approver12
a0GP3000002gp9vMAA29/11/2023 14:12 Draft1

 

The goal is to add a new column called "EnteredStatus" which returns the CreatedDate for the corresponding row where Acc_NewProjectChangeRequestStatus__c = the current record value for Acc_PreviousProjectChangeRequestStatus__c, i.e. the date the row entered the Status it's now changing from. (hope that makes sense!!)

 

In many cases a unique Acc_ProjectChangeRequest__c may bounce back and forward between the same Status pairs a couple of times, so I have added a custom column called RankByDate that adds an incremental number to rows that share the same Acc_ProjectChangeRequest__c - the idea being to then (somehow) use this to return the CreatedDate for the most recent time a record entered a given status.

But now I'm well and truly stuck!!  I have tried all sorts of code and even reached out to ChatGPT for help, but simply cannot figure out how to add this new "EnteredStatus" column so it returns the value I need for each row.

Please help!! 😩

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

Hi @ChrisW764 ,

Here some steps that I want to share, you can check them if they suitable for your requirement.

Here is my test data:

vheqmsft_1-1704275884943.png

1.Create a calculate column

 

EnteredStatus = 
CALCULATE (
        MAX ( 'Status Change'[CreatedDate] ),
        FILTER (
            'Status Change',
            'Status Change'[Acc_ProjectChangeRequest__c] = EARLIER ( 'Status Change'[Acc_ProjectChangeRequest__c] )
                && 'Status Change'[Acc_NewProjectChangeRequestStatus__c] = EARLIER ( 'Status Change'[Acc_PreviousProjectChangeRequestStatus__c] )
                && 'Status Change'[RankByDate] < EARLIER('Status Change'[RankByDate]
        )
    )
)

 

2.Final output

vheqmsft_0-1704275960485.png

 

Best Regards,

Albert He

View solution in original post

3 REPLIES 3
v-heq-msft
Community Support
Community Support

Hi @ChrisW764 ,

Here some steps that I want to share, you can check them if they suitable for your requirement.

Here is my test data:

vheqmsft_1-1704275884943.png

1.Create a calculate column

 

EnteredStatus = 
CALCULATE (
        MAX ( 'Status Change'[CreatedDate] ),
        FILTER (
            'Status Change',
            'Status Change'[Acc_ProjectChangeRequest__c] = EARLIER ( 'Status Change'[Acc_ProjectChangeRequest__c] )
                && 'Status Change'[Acc_NewProjectChangeRequestStatus__c] = EARLIER ( 'Status Change'[Acc_PreviousProjectChangeRequestStatus__c] )
                && 'Status Change'[RankByDate] < EARLIER('Status Change'[RankByDate]
        )
    )
)

 

2.Final output

vheqmsft_0-1704275960485.png

 

Best Regards,

Albert He

Hi @v-heq-msft

 

You are a star!!  😁  

This code works perfectly - thank you so much! 

 

 

ChrisW764
Regular Visitor

To summairse, I need the DAX to return the CreatedDate of the record that matches the following criteria;

  1. Acc_NewProjectChangeRequestStatus__c = Acc_PreviousProjectChangeRequestStatus__c (current record)
  2. RankByDate value < RankByDate value (current record)
  3. Acc_ProjectChangeRequest__c is the same as current record

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.