Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Convert minutes to HH:MM - Calculated column

I have a field in Power BI which gives me the minutes number.

 

Example :- 14 

 

I need to convert it to the format HH:MM. Please help

 

Examples 

 

-- 14 need to be changed as 00:14

-- 62 need to be changed as 01:02

-- 70 need to be changed as 01:10

  • HI Anonymous 

    you can create a column with below code:-

     

    In Hours and Minutes = 
    var _Minues='Convert HHM'[Column1]
    var _Hours=int( _Minues/60)
    var _RemMinutes=MOD(_Minues, 60)
    return
      _Hours&":"&IF(_RemMinutes< 10,"0"&_RemMinutes,_RemMinutes)

     

    Thanks,

    Samarth

4 Replies

  • Samarth_18's avatar
    Samarth_18
    Icon for Community Champion rankCommunity Champion

    HI Anonymous 

    you can create a column with below code:-

     

    In Hours and Minutes = 
    var _Minues='Convert HHM'[Column1]
    var _Hours=int( _Minues/60)
    var _RemMinutes=MOD(_Minues, 60)
    return
      _Hours&":"&IF(_RemMinutes< 10,"0"&_RemMinutes,_RemMinutes)

     

    Thanks,

    Samarth

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi

      I have a field in Power BI which gives me the minutes number.

       

      Example :- 186

       

      I need to convert it to the format HH:MM. Please help

       

      The above dax does not work

       

       

    • lroush259's avatar
      lroush259
      New Member

      This solution worked perfectly for me when I found it for my project. My only outstanding problem is blank values showing up with  :  and not zeros. Another option would be to exclude those with zero but I am not able to filter due to the colon. Any ideas? 

       

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

       

      Unsure what I have done incorrectly, it does not pick up the column name "Loading TAT(mins)"