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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.