Forum Discussion
Substract from Different Rows on a Table
v-alq-msft Can you do the same but with the timestamp in a different order and different dates? I see that it works in yours but mine has different dates and times and does not show the same results.
Hi, Anonymous
I modified data to reproduce your scenario.
Table:
You may create an index column in Power Query and then modify the measure or column as below.
Calculated column:
Result Column =
var tab =
ADDCOLUMNS(
ALL('Table'),
"Start",[Status Start Date]+[Start Time],
"End",[Status End Date]+[End Time]
)
var totalseconds =
DATEDIFF(
MAXX(
FILTER(
tab,
[Index]=EARLIER('Table'[Index])-1
),
[End]
),[Status Start Date]+[Start Time],SECOND
)
var m =
COALESCE(INT(DIVIDE(totalseconds,60)),0)
var s = COALESCE(MOD(totalseconds,60),0)
return
m&":"&s
Measure:
Result Measure =
var tab =
ADDCOLUMNS(
ALL('Table'),
"Start",[Status Start Date]+[Start Time],
"End",[Status End Date]+[End Time]
)
var totalseconds =
DATEDIFF(
MAXX(
FILTER(
tab,
[Index]=MAX('Table'[Index])-1
),
[End]
),MAX([Status Start Date])+MAX([Start Time]),SECOND
)
var m =
COALESCE(INT(DIVIDE(totalseconds,60)),0)
var s = COALESCE(MOD(totalseconds,60),0)
return
m&":"&s
Best Regards
Allan
If this post helps,then consider Accepting it as the solution to help other members find it faster.
- Anonymous5 years agoNot applicable
First, thank you so much for the hand. Im still getting the following miscalculation. I think you are close but not quite getting the correct calculation or formatting. Your table is still organized even though it shows a gap between 5:17 and 6:31 pm. Can you try with the table having unsorted date times with 2 different users?
Again, appreciate the time.