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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Shree_185
Helper I
Helper I

SLA Help : How to convert minutes to DDHHMMSS in Direct Query

Hello everyone - I need your help to convert Minutes to DDHHMMSS format. As I am using an SQL server direct query Format function doesn't support it. Can anyone help me here?

 

Shree_185_0-1641169797634.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Shree_185 ,

 

Format function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

 

You can create a measure using format function.

 

Format Measure = 
VAR _day =
    QUOTIENT ( MAX ( 'minutes'[Minutes] ), 60 * 24 )
VAR _hour =
    FORMAT ( QUOTIENT ( MOD ( MAX ( 'minutes'[Minutes] ), 60 * 24 ), 60 ), "00" )
VAR _minute =
    FORMAT ( MOD ( MAX ( 'minutes'[Minutes] ), 60 ), "00" )
RETURN
    _day & "day " & _hour & ":" & _minute & ":" & "00"

 

vstephenmsft_0-1641351816638.png

 

If you want a calculated column, you can create like

 

Format Column = 
VAR _day =
    QUOTIENT ( [Minutes] , 60 * 24 )
VAR _hour =
     QUOTIENT ( MOD ( 'minutes'[Minutes] , 60 * 24 ), 60 )
VAR _minute =
  MOD ( [Minutes] , 60 )
RETURN
    _day & "day " & _hour & ":" & _minute & ":" & "00"

 

vstephenmsft_1-1641351881930.png

 

But it does not look as beautiful as the metric, because the FORMAT function cannot be used.

You can add IF function to judge.

Format Column =
VAR _day =
    QUOTIENT ( [Minutes], 60 * 24 )
VAR _hour =
    QUOTIENT ( MOD ( 'minutes'[Minutes], 60 * 24 ), 60 )
VAR _minute =
    MOD ( [Minutes], 60 )
RETURN
    IF (
        _hour >= 10
            && _minute >= 10,
        _day & "day " & _hour & ":" & _minute & ":" & "00",
        IF (
            _hour >= 10
                && _minute < 10,
            _day & "day " & _hour & ":0" & _minute & ":" & "00",
            IF (
                _hour < 10
                    && _minute >= 10,
                _day & "day 0" & _hour & ":" & _minute & ":" & "00"
            )
        )
    )

vstephenmsft_0-1641362383668.png

 

You can check more details from the attachment.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Shree_185 ,

 

Format function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

 

You can create a measure using format function.

 

Format Measure = 
VAR _day =
    QUOTIENT ( MAX ( 'minutes'[Minutes] ), 60 * 24 )
VAR _hour =
    FORMAT ( QUOTIENT ( MOD ( MAX ( 'minutes'[Minutes] ), 60 * 24 ), 60 ), "00" )
VAR _minute =
    FORMAT ( MOD ( MAX ( 'minutes'[Minutes] ), 60 ), "00" )
RETURN
    _day & "day " & _hour & ":" & _minute & ":" & "00"

 

vstephenmsft_0-1641351816638.png

 

If you want a calculated column, you can create like

 

Format Column = 
VAR _day =
    QUOTIENT ( [Minutes] , 60 * 24 )
VAR _hour =
     QUOTIENT ( MOD ( 'minutes'[Minutes] , 60 * 24 ), 60 )
VAR _minute =
  MOD ( [Minutes] , 60 )
RETURN
    _day & "day " & _hour & ":" & _minute & ":" & "00"

 

vstephenmsft_1-1641351881930.png

 

But it does not look as beautiful as the metric, because the FORMAT function cannot be used.

You can add IF function to judge.

Format Column =
VAR _day =
    QUOTIENT ( [Minutes], 60 * 24 )
VAR _hour =
    QUOTIENT ( MOD ( 'minutes'[Minutes], 60 * 24 ), 60 )
VAR _minute =
    MOD ( [Minutes], 60 )
RETURN
    IF (
        _hour >= 10
            && _minute >= 10,
        _day & "day " & _hour & ":" & _minute & ":" & "00",
        IF (
            _hour >= 10
                && _minute < 10,
            _day & "day " & _hour & ":0" & _minute & ":" & "00",
            IF (
                _hour < 10
                    && _minute >= 10,
                _day & "day 0" & _hour & ":" & _minute & ":" & "00"
            )
        )
    )

vstephenmsft_0-1641362383668.png

 

You can check more details from the attachment.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Shree_185 , Try in power query

 

#duartion(0,0,[Minutes],0)

 

 

or a text column using DAX

Quotient([Minutes],60*24) & "days " Quotient(mod([Minutes],60*24),60) &":" & Quotient(mod(mod([Minutes],60*24),60),60) &":0"

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors