Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
morther
Helper I
Helper I

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

1 ACCEPTED SOLUTION

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.

View solution in original post

13 REPLIES 13

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.

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.

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.

I am referring to the Card visual:

 

InkedCapture_LI.jpg

so strange that this is not working for me.  Do you think it might have something to do with the datatype of the source?

What is the source?  Are you using DirectQuery or Import?

Datatype is Decimal Number and this is an import

So you have a field in your data that gives downtime minutes, and you tried putting your measure into a Card?

 

Here is my result (using 99 minutes as your example showed):

 

Capture.PNG

tablepicture.JPG

does that picture work or do you need something else?

 

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.

I think this statement might be correct.  I tested this on another table and it worked just fine. you can see from the picture supplied that the DowntimeMinutes shows properly, but when I look table itsetable.JPGlf, DowntimesMinutes column shows then number 60 iin every cell.

 

 

Why not change your hourNo variable to this:

 

hourNo = ROUNDDOWN(EventLogDetail[DowntimeMinutes]/60, 0)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors