Forum Discussion

smithub's avatar
smithub
Helper I
2 years ago
Solved

How long at each stage

Hi all,  Trying to create a measure that calculates the amount of days at each stage. The bottom table has sample data from 2 tables.   Table  Column Table 1  Case ID Table 2  Stage ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi smithub ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a table.

    Table = FILTER('Table1','Table1'[Stage] in VALUES('Table2'[Stage]))

    (3)We can create a column.

    Days = 
    var _min=CALCULATE(MIN('Table'[Status Date]),FILTER('Table','Table'[Stage]=EARLIER('Table'[Stage])))
    var _max=CALCULATE(MIN('Table'[Status Date]),FILTER('Table','Table'[Stage]>EARLIER('Table'[Stage])))
    var _max2=CALCULATE(MIN('Table'[Status Date]),FILTER('Table','Table'[Stage]=" End Stage"))
    return SWITCH(TRUE(),
    'Table'[Status Date]=_min && [Stage] <> " Stage 5" && [Stage]<>" End Stage",DATEDIFF(_min,_max,DAY),
    'Table'[Status Date]=_min && [Stage] = " Stage 5" ,DATEDIFF(_min,_max2,DAY))
    

    (4) Then the result is as follows.

    Best Regards,

    Neeko Tang

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