TRUE/FALSE SWITCH statement

Could someone help me understand why this formula throws an error?

SWITCH(1=1,TRUE,“Y”,FALSE,“N”)

Thanks.

TRUE and FALSE aren’t possible outcomes of the expression you are trying to evaluation (1=1). That’s why your formula there is failing.

If you put just 1=1 as a formula into a formula field, you’ll get a return value of 1, which is the numeric equivalent of true.

If you put just 1=2 as a formula into a formula field, you’ll get a return value of 0, which is the numeric equivalent of false.

However, Airtable’s SWITCH() function appears to not even be able to evaluate this correctly either:

SWITCH(
   1 = 1,
   1, "Y",
   0, "N"
)

Which is odd… but, a SWITCH() statement is really not the best option for a binary/boolean comparison anyhow – it’s a bit overkill, since it’s meant to handle more than just either/or outcomes for an expression.

You can get the outcome you want with a simple IF() statement:

IF(
   1 = 1,
   "Y",
   "N"
)
1 Like

Thank you, I did have a more complex use in mind.
It does seem though, that SWITCH does not accept logical conditions in this manner.