Forum Discussion

CharmaineSilver's avatar
CharmaineSilver
Qrew Member
5 years ago

Formulas and checkboxes

Hi.
Just started on my first formula in QB and am having trouble with a check box. 
Trying to say if half day is not checked  add 1 day and if checked add 1.5 days.
Get the error message, expecting Boolean but found number on my second row of the formula.
The field is formula- numeric.
My first and last day fields are dates.


If([Half day],"No",
WeekdaySub([Last day of leave],[First day of leave])+1,
WeekdaySub([Last day of leave],[First day of leave])+1.5)

All help will be most appreciated

------------------------------
Charmaine Silverman
------------------------------

1 Reply

  • I think you have a syntax error.  This should work:
    If([Half day],
    WeekdaySub([Last day of leave],[First day of leave])+1,
    WeekdaySub([Last day of leave],[First day of leave])+1.5)
    ā€‹

    There are two ways you can use the if statement in Quick Base.  You can either have a single test:  If(condition, true-result, false-result) - Read If condition is true, do true-result otherwise do false-result.

    Alternatively, you can chain several conditions as an if-else:  If(condition1, result1, condition2, result2, false-result) - Read if condition1 is true, do result1.  If condition1 is not true and condition2 is true, do result2.  If condition1 and condition2 are both not true, do false-result.  

    You original formula was structured like the later so Quick Base expected WeekdaySub([Last day of leave], [First day of leave])+1 to be a condition and evaluate to a boolean value (true/false).

    ------------------------------
    Nathan Hawe
    ------------------------------