Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Update custom text column calculation to time type!

Hello, I am attempting to convert this decimal column into an hours and minutes column.    My formula below works well, but creates the column as a text column not a number column.    Adjusted H...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Anonymous ,

    I create a table as you mentioned.

    Then I think you can change your DAX code, it will give you Date/Time type. You can change format as you like.

    Column = 
    VAR _hrs =
        QUOTIENT ( '12 1/2'[Average Adjusted Hours], 1 )
    VAR _mins =
        MOD ( '12 1/2'[Average Adjusted Hours] * 60, 60 )
    RETURN
        TIME ( _hrs, _mins, 0 )

    Next I think you can create another calculated column.

    Total Adjusted Hours =
    VAR TotalMinutes =
        SUMX ( '12 1/2', '12 1/2'[Column] * 60 )
    VAR Hours =
        QUOTIENT ( TotalMinutes, 60 )
    VAR Minutes =
        MOD ( TotalMinutes, 60 )
    RETURN
        TIME ( Hours, Minutes, 0 )

     

     

    Best Regards

    Yilong Zhou

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