Help

Roundup function in an IF statement

Topic Labels: Formulas
4344 11
cancel
Showing results for 
Search instead for 
Did you mean: 
Greg_Stevens
4 - Data Explorer
4 - Data Explorer

I am attempting to write an equation but I cannot get Airtable to do what I want. What I am asking is that if “Total Time Worked” is greater than or equal to 7 hours and 45 minutes to round it up to 8 hours. However if “Total Time Worked” is less than 7 hours and 45 minutes do nothing and leave as is. I am trying to calculate this for payout purposes at work and making sure that anyone working at least 7:45 gets a full 8 hours but anyone working 7:44 hours or less simply gets paid for the time they worked.

This is what I wrote: IF({Total Time Worked} >= 7.75, ROUNDUP(7.75,0))

What am I doing wrong here? Any help would be greatly appreciated. Problem here is once this equation is entered what Airtable is now doing is round all hours above 7.5 to 8.

11 Replies 11

In that case, I’m guessing {Total Time Worked} is formatted as a duration, not a number. It’s the same issue: durations also default to seconds. In either case, you’re comparing ~27,900 to 7.75: It’s always going to round up.

If you want to keep {Total Time Worked} as a duration — which makes sense, as it will display in h:mm format — but your calculated (rounded up) hours to be decimal, your formula needs to be

IF(
    {Total Time Worked}>=7.75*3600,
    ROUNDUP(7.75,0),
    {Total Time Worked}/3600
    )

(Or you could always just replace ROUNDUP(7.75,0) with 8.)

Alternatively, if you want both {Total Time Worked} and the calculated field to be durations, you need

IF(
    {Total Time Worked}>=7.75*3600,
    ROUNDUP(7.75,0)*3600,
    {Total Time Worked}
    )
Greg_Stevens
4 - Data Explorer
4 - Data Explorer

OMG it worked! Thank you so much. If you were here I could almost kiss you! I have been stuck trying to do this for almost 24 hours and you’ve helped me so much. A thousand time over thank you W_Vann_Hall!