Forum Discussion
Wrong Time Calculation
- 1 year ago
Hi timbckr812 - First, convert the production time to a numerical value, i.e., seconds, to ensure proper summing.
create a measure as follows;
Production Time per Unit =
VAR TotalTimeSeconds = SUMX('Production Orders',
(HOUR('Production Orders'[Production Time]) * 3600) +
(MINUTE('Production Orders'[Production Time]) * 60) +
SECOND('Production Orders'[Production Time]))
VAR TotalQuantity = SUM('Production Orders'[Quantity])
VAR TimePerUnitSeconds = TotalTimeSeconds / TotalQuantity
RETURN
FORMAT(TIME(0,0,TimePerUnitSeconds), "hh:mm:ss")It sum the total production time in seconds and divide by the total quantity. please check the above and let know.
- 1 year ago
Hello timbckr812 ,
You can try below dax :
Time per Unit =
VAR TotalMinutes = SUMX(
'Production Orders',
HOUR('Production Orders'[Production Time]) * 60 +
MINUTE('Production Orders'[Production Time]) +
SECOND('Production Orders'[Production Time]) / 60
)
VAR TotalQuantity = SUM('Production Orders'[Quantity])
VAR MinutesPerUnit = TotalMinutes / TotalQuantity
RETURN
TIME(INT(MinutesPerUnit / 60), INT(MOD(MinutesPerUnit, 60)), 0)Cheers
- 1 year ago
Hi timbckr812
I can't replicate your expected result using your sample data even if the time per unit is evaluated separately for each order and then summed up in the total row but I am definitely not getting 19:52:07
Attached is the sample pbix used in the screenshot.
Hello timbckr812 ,
You can try below dax :
Time per Unit =
VAR TotalMinutes = SUMX(
'Production Orders',
HOUR('Production Orders'[Production Time]) * 60 +
MINUTE('Production Orders'[Production Time]) +
SECOND('Production Orders'[Production Time]) / 60
)
VAR TotalQuantity = SUM('Production Orders'[Quantity])
VAR MinutesPerUnit = TotalMinutes / TotalQuantity
RETURN
TIME(INT(MinutesPerUnit / 60), INT(MOD(MinutesPerUnit, 60)), 0)
Cheers
Works perfect, thank!!