Skip to main content

Function to Round

Hi All,
I have column of duration in second and i need to round it : first to 60 and to 30 by creating two column.
Using @Round isn't very helpful for me, so ; is there any function ? or should i use @Round with another function,
Thank you.

Brian Element Thu, 10/26/2017 - 07:17

Hi Ahmed,

I am not sure I understand what you want to do, could you give me an example of the before and what you expect from the two new fields.

Thanks

Brian

Ahmed Thu, 10/26/2017 - 09:19

Hi Brian,
Okay, for example; i have coulmn named duration and I would like to rounded them to 30 or to 60 
in Excel i use : Ceiling  (see the file uploaded)
Thank you.
 

Brian Element Thu, 10/26/2017 - 09:48

Hi Ahmed,

Thanks for the spreadsheet.  Here are the equations I came up with.

@if(@Round(DURATION_SECOND, 30) < DURATION_SECOND, @Round(DURATION_SECOND + 15, 30), @Round(DURATION_SECOND, 30))

@if(@Round(DURATION_SECOND, 60) < DURATION_SECOND, @Round(DURATION_SECOND + 30, 60), @Round(DURATION_SECOND, 60))

What I did since round always rounds up or down it doesn't work in your scenario as you want it to always round up.  So I first test to see if the result is smaller then the amount rounding, meaning that it rounded down, if it does I add half the amount (15 for 30 and 30 for 60) to it and round again to force it to round up.

Thanks

Brian