Forum Discussion
Datediff Calculation
- 5 years ago
Hi ddurosier
Try something like this
Measure2 = SUMX ( VALUES ( Durations[Prod] ), [Measure1] ) Measure2_Formatted = VAR __HH = FLOOR ( [Measure2], 1 ) VAR __MM = ROUND ( ( [Measure2] - __HH ) * 60, 0 ) RETURN __HH & ":" & __MM(I don't remember if there's a function that just takes the decimal part of a number in DAX, hence the complex formula)
Hope this helps
David
- 5 years ago
Hi, ddurosier
Based on your description, I created data to reporduce your scenario. The pbix file is attached in the end.
Table:
You may create a measure as below.
Result = var tab = SUMMARIZE( 'Table', 'Table'[Prod], "Re", DATEDIFF( MIN('Table'[DateStringProd]), MAX('Table'[DateStringProd]), MINUTE ) ) var result = SUMX( tab, [Re] ) return INT(DIVIDE(result,60))&"hr "&MOD(result,60)&"min"Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, ddurosier
Based on your description, I created data to reporduce your scenario. The pbix file is attached in the end.
Table:
You may create a measure as below.
Result =
var tab =
SUMMARIZE(
'Table',
'Table'[Prod],
"Re",
DATEDIFF(
MIN('Table'[DateStringProd]),
MAX('Table'[DateStringProd]),
MINUTE
)
)
var result =
SUMX(
tab,
[Re]
)
return
INT(DIVIDE(result,60))&"hr "&MOD(result,60)&"min"
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.