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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
johnmay
Regular Visitor

Urgent! Days interval same id different status

Hello people!

Please, I need help to create a measure that is able to analyze the range of days from an "accept" status to the next in the same ID. However, there are 3 different scenarios:

 

10670 - If I have the status "proposal" I calculate the range of days from the status "accept" to it (in this case the interval is 10 days)

 

10671 - If I don't have the "proposal" I calculate from "accept" until the next status (in this case the next status is "done" and the interval will be 9 days)

 

10672 - If I don't have any status after "accept" I calculate the interval until today (14 days interval )

 

I need this measure for a tachometer view that will report the average of the days that in this case will be 10 + 9 + 14 / 3 IDs = 11 days

 

Work Item Id

STATE DATE

State

10670

23/04/2020

In Progress

10670

06/05/2020

Accept

10670

16/05/2020

Proposal

10671

23/04/2020

In Progress

10671

06/05/2020

Accept

10671

15/05/2020

Done

10672

23/04/2020

In Progress

10672

06/05/2020

Accept

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Same answer as the other one of these:

Measure = 
    VAR __Table = 'Table'
    VAR __States = SELECTCOLUMNS(__Table,"State",[State])
    VAR __MaxDate = MAX('Table'[STATE DATE])
    VAR __MaxStatus = MAXX(FILTER('Table',[STATE DATE] = __MaxDate),[State])
RETURN
    SWITCH(TRUE(),
        "Proposal" IN __States,
                VAR __date1 = MAXX(FILTER(__Table,[State] = "Proposal"),[STATE DATE])
                VAR __date2 = MAXX(FILTER(__Table,[State] = "Accept"),[STATE DATE])
            RETURN
                (__date1 - __date2) * 1.,
        __MaxStatus = "Accept",(TODAY() - __MaxDate) * 1.,
            VAR __date1 = MAXX(FILTER(__Table,[State] = "Accept"),[STATE DATE])
            VAR __date2 = MINX(FILTER(__Table,[State] <> "Accept" && [STATE DATE] > __date1),[STATE DATE])
        RETURN
            (__date2 - __date1) * 1.
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Same answer as the other one of these:

Measure = 
    VAR __Table = 'Table'
    VAR __States = SELECTCOLUMNS(__Table,"State",[State])
    VAR __MaxDate = MAX('Table'[STATE DATE])
    VAR __MaxStatus = MAXX(FILTER('Table',[STATE DATE] = __MaxDate),[State])
RETURN
    SWITCH(TRUE(),
        "Proposal" IN __States,
                VAR __date1 = MAXX(FILTER(__Table,[State] = "Proposal"),[STATE DATE])
                VAR __date2 = MAXX(FILTER(__Table,[State] = "Accept"),[STATE DATE])
            RETURN
                (__date1 - __date2) * 1.,
        __MaxStatus = "Accept",(TODAY() - __MaxDate) * 1.,
            VAR __date1 = MAXX(FILTER(__Table,[State] = "Accept"),[STATE DATE])
            VAR __date2 = MINX(FILTER(__Table,[State] <> "Accept" && [STATE DATE] > __date1),[STATE DATE])
        RETURN
            (__date2 - __date1) * 1.
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you so much! It works perfectly.

Sweet! Please try not to cross post next time! 🙂


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.