Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Rounding up time

Hey guys, I've got the following situation below and basically in the column where the time is, I need to round it up to only hours, if its above 40 minutes. So lets say its 15:30 then it displays 15, but if its 15:40 then it rounds up to 16 hours. Any way to achieve that by adjusting the code?
Any help appreciated. 

 

  • Fowmy's avatar
    Fowmy
    5 years ago

    Anonymous 

    You need to use the seconds as input for my formula, it converts it into time. 

    I have attached your file with the column added.

    You can download the file: HERE

    ________________________

    If my answer was helpful, please consider Accept it as the solution to help the other members find it

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube  LinkedIn

15 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    Please try a column expression like this to get your desired result.

     

    Rounded Time = var hours = HOUR('Table'[Time])
    var minutes = MINUTE('Table'[Time])
    return IF(minutes>=40, hours +1, hours)
     
    Regards,
    Pat
     
  • Anonymous 

    Time rounded as expected:

    Rounded Time = 
    IF( MINUTE([TIME]) >= 40,  
        MROUND([Time], 1/24 ),
        HOUR([Time])/24
    )

    ________________________

    If my answer was helpful, please consider Accept it as the solution to help the other members find it

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube  LinkedIn

     



    • Anonymous's avatar
      Anonymous
      Not applicable

      Fowmy mahoneypat This is what i get: Might be the reason that Im using charlie eidens duration and displaying time as a whole number.

       

      • Fowmy's avatar
        Fowmy
        Super User

        Anonymous 

        My formula is based on Time data type column, if you have any other type, I need to do it differently.

        You may share a sample PBIX file to check.

        ________________________

        If my answer was helpful, please consider Accept it as the solution to help the other members find it

        Click on the Thumbs-Up icon if you like this reply 🙂

        YouTube  LinkedIn