Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here
Jun 11, 2019 08:57 AM
Could someone help me understand why this formula throws an error?
SWITCH(1=1,TRUE,“Y”,FALSE,“N”)
Thanks.
Jun 11, 2019 11:42 AM
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"
)
Jun 11, 2019 11:53 AM
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.