Jun 16, 2020 02:05 AM
Hi,
I have issues with a checkbox that doesn’t work proper with my IF AND formula.
Or more correctly, when checkbox =“1” formula works fine, but when checkbox =“0” it doesn’t. As far as I can tell, an empty checkbox is supposed to be =“0”, right?
Formula looks like this:
IF(AND({Win}=‘Yes’, {EW}=“1”), (({Stake} / 2) * {Odds}) + (({Stake} / 2) * {EW Odds}), IF(AND({Win}=‘Yes’, {EW}=“0”), {Stake} * {Odds},
IF(AND({Win}=‘EP’, {EW}=“1”), {Stake} / 2 * {EW Odds}, {Stake} * 0)))
Works like a charm as long as the checkbox is marked, but when it’s not the 2nd Row of the formula is not working and instead the ELSE thing at the end of Row 3 kicks in.
I’m a total beginner at this so my apologies for novice language or stupid question.
Many thanks!
Best regards,
Marcus Sjöberg
Solved! Go to Solution.
Jun 16, 2020 05:44 AM
I think the problem in your formulas is you put 1 or 0 in quotes. Remove the quotes and it should work.
See here: https://support.airtable.com/hc/en-us/articles/217113757-Using-checkbox-fields-in-formulas
Jun 16, 2020 05:44 AM
I think the problem in your formulas is you put 1 or 0 in quotes. Remove the quotes and it should work.
See here: https://support.airtable.com/hc/en-us/articles/217113757-Using-checkbox-fields-in-formulas
Jun 16, 2020 05:51 AM
Yes that made all the difference! Thank you so much for taking the time to help me out :slightly_smiling_face:
Jun 16, 2020 08:21 AM
FWIW, you could also drop the 1 and 0 entirely. An undocumented feature of referencing fields in formulas is that using a field name alone will return True if the field contains anything, and False if it’s empty. Here’s your formula with that change applied:
IF(AND({Win}='Yes', {EW}), (({Stake} / 2) * {Odds}) + (({Stake} / 2) * {EW Odds}),
IF(AND({Win}='Yes', {EW}), {Stake} * {Odds},
IF(AND({Win}='EP', {EW}), {Stake} / 2 * {EW Odds}, {Stake} * 0)))