Forum Discussion
How long at each stage
- Anonymous2 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.
You could pivot the Stage column by first removing duplicates from Case ID & Stage combined:
let
Source = <YOUR SOURCE HERE>,
#"Removed Duplicates" = Table.Distinct(Source, {"Case ID", " Stage"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Duplicates",{{" Status Date", type date}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[#" Stage"]), " Stage", " Status Date", List.Sum)
in
#"Pivoted Column"
Then you could either create further Custom Columns like
Days In Stage 1 = [#" Stage 2"]-[#" Stage 1"]
or you could just create measures to calculate these values
Hi brokencornets,
Thanks for your reply, unfortunately I don't understand any of this and I believe there could be an easier solution by creating a measure with DAX?