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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hariganesh
Frequent Visitor

Help with DAX: Event status table

Hi

 

I have a situation where i have a table with entities with different stages, completion status, and status dates. I'm trying to calculate the average days spent between status changes (e.g. average time to move from status 1 to status 2). I was able to figure out a method to use calculate tables to calculate counts of entities completing multiple stages. I have attached a a picture below for details

 

Appreciate any help with this

 

Regards

 

Hari

Sample.png

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @hariganesh,

 

Please try a measure like below.

Measure =
VAR newCompletedDate =
    IF (
        ISBLANK ( MAX ( 'Table1'[Completed Date] ) ),
        TODAY (),
        MIN ( 'Table1'[Completed Date] )
    )
VAR preDate =
    CALCULATE (
        MAX ( 'Table1'[Completed Date] ),
        FILTER (
            ALL ( 'Table1' ),
            'Table1'[Completed Date] < newCompletedDate
                && 'Table1'[Entity] = MAX ( [Entity] )
        )
    )
RETURN
    DATEDIFF ( preDate, newCompletedDate, DAY )
Measure 2 =
AVERAGEX (
    SUMMARIZE ( 'Table1', Table1[Entity], Table1[Event], "Value", [Measure] ),
    [Value]
)

Help_with_DAX_Event_status_table

Help_with_DAX_Event_status_table2

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-jiascu-msft
Employee
Employee

Hi @hariganesh,

 

Please try a measure like below.

Measure =
VAR newCompletedDate =
    IF (
        ISBLANK ( MAX ( 'Table1'[Completed Date] ) ),
        TODAY (),
        MIN ( 'Table1'[Completed Date] )
    )
VAR preDate =
    CALCULATE (
        MAX ( 'Table1'[Completed Date] ),
        FILTER (
            ALL ( 'Table1' ),
            'Table1'[Completed Date] < newCompletedDate
                && 'Table1'[Entity] = MAX ( [Entity] )
        )
    )
RETURN
    DATEDIFF ( preDate, newCompletedDate, DAY )
Measure 2 =
AVERAGEX (
    SUMMARIZE ( 'Table1', Table1[Entity], Table1[Event], "Value", [Measure] ),
    [Value]
)

Help_with_DAX_Event_status_table

Help_with_DAX_Event_status_table2

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you, i ended up using a different method as the stages were dynamic and could grow,

hariganesh
Frequent Visitor

For clarification, I'm looking to see if there's a way to calculate the average days between a set of stages (e.g. stage1-2, Stage 2-3) for completed entries as a measure.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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