Forum Discussion
Calculation function only returning minutes
I have created a New Column called Downtime. It is supposed to take the total Downtime Minutes and break it into Days, Hours, and Minutes. It is pulling the remainder minutes properly but is not adding the hours beforehand.
(Source Column)
Downtime Minutes Downtime
99.00 0 day 00 hours 33 Min
This should read 0 day 01 hours 33 Min, but is missing the hour.
Below is the DAX code:
Downtime =
VAR dayNo =
INT ( EventLogDetail[DowntimeMinutes] / 1440 )
VAR hourNo =
INT ( MOD ( EventLogDetail[DowntimeMinutes], 1440 ) / 60 )
VAR minuteNo =
MOD ( MOD ( EventLogDetail[DowntimeMinutes], 1440 ), 60 )
RETURN
dayNo & " day "
& FORMAT ( hourNo, "#00" )
& " hours "
& FORMAT ( minuteNo, "#00" )
& " Min"
Any help would be greatly appreciated.
Thanks,
Mike
Can you post some sample data of your downtime table? The issue might be that you need to specify some type of aggregation for your downtime minutes column, rather than the raw column reference you are providing. In my example, I just hard coded in the number 99, but if you have multiple values in your downtime minutes column, it wont work by just giving the column name.
13 Replies
- dkay84_PowerBIMicrosoft Employee
Why not change your hourNo variable to this:
hourNo = ROUNDDOWN(EventLogDetail[DowntimeMinutes]/60, 0)
- dkay84_PowerBIMicrosoft Employee
I tried both yours and mine and they both work for me. when put into a card I get "0 days 01 hours 39 mins" for your 99 minutes value.
- mortherHelper I
Thanks for the reply to my post.
Can you explain what you mean when you say "when put into a card" Maybe I can try that to help me understand why this is not working.
- dkay84_PowerBIMicrosoft Employee
I am referring to the Card visual:
- dkay84_PowerBIMicrosoft Employee
Yes the data view helped. I created 3 calculated columns (days, hours, mins) and then a fourth calc column to concantenate, using your exact DAX, and it worked.