Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
4 years ago
Solved

Converting Decimal Hour to HH:MM Format

Hi All,   I am trying to convert a column which has value stored as decimal hour to hh:mm format. For eg: 2.78 - 02:46 25.56 - 25:33 Also attached a pbix file for reference.  Quick help will b...
  • v-jingzhang's avatar
    4 years ago

    Hi Syndicate_Admin 

     

    Try this column

    Column = 
    VAR _hours = INT('Table'[TIMEDECHOURS])
    VAR _minutes = ROUND(('Table'[TIMEDECHOURS]-_hours)*60,0)
    RETURN
    RIGHT("0"&_hours,2)&":"&_minutes

     

    With above code, the column is of Text type. If the hours part is larger than or equal to 100 hours, it would return an incorrect value. You need to modify the hours part in that case. And I used ROUND function for minutes part. You could replace it with ROUNDUP or ROUNDDOWN if needed. 

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.