Forum Discussion
ddurosier
5 years agoFrequent Visitor
Datediff Calculation
Looking for some assistance for a correct Output. Scenario: I have TableA that shows the time (datestringProd) column of each change made for a product# (ProductColumn). One Product number can h...
- 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.
dedelman_clng
5 years agoCommunity Champion
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
- ddurosier5 years agoFrequent Visitor
I will give it a shot ofr that part.