Quick Syntax Question about If Statement

Hi, thanks for reading.

I’m having a syntax issue - I don’t seem to have the right structure for a formula I’m using in a field. The formula should subtract hours worked from hours due, but not allow negative numbers. So if someone worked 5 hours and only 3 were due, I don’t want -2, just 0 in the field.

Here’s how I had done it in another program:

Here’s my Panorama X attempt from reading the docs, but I’m doing something wrong:
?(HoursWorked < HoursRequired), (HoursRequired - HoursWorked), 0)

Thank you in advance for helping me get this.

You have one too many right parentheses. It should be

?(HoursWorked < HoursRequired, (HoursRequired - HoursWorked), 0)

Actually, you could drop the ones in the middle as well. Only the first and last are really needed.

1 Like

You have an extra right parenthesis. Aha, Dave beat me too it.

One clarification, in this case this isn’t a statement, it’s a function. Unfortunately the difference between statements (used in program code) and functions (used in formulas) is often confusing. I wrote a post about this topic last month, hope it might be helpful to you.

1 Like

Thanks so much Dave, worked like a charm.

Thank you so much! Heading to read your post now :blush:

Have a great night! (And yes, that emoji was so I could earn my emoji badge!)

You must have used Discourse before :rofl: