Help

Airtable error with invalid AND condition. Formular does not abort after first mismatch.

1475 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Partyborn
6 - Interface Innovator
6 - Interface Innovator

Hi!

I have this small test function to reproduce my issue:

```

IF(AND(5=6,LOWER(50)), 'ok', 'not ok')
```
Normally I would expect this to output "not ok", but it gives an error. The AND operation does not stop after the first mismatch. Usualy in programming languages you would stop then and no further arguments will be evaluated.
This looks like a bug, right?
Does anyone know how to work around this?
3 Replies 3

Hey @Partyborn!

There aren't any bugs present in the behavior you're describing.
Your test formula actually correctly returns an error.

IF(
AND(
5 = 6,
LOWER(50)
),
"ok",
"not okay"
)

The problem with this test formula is in the LOWER function.

The LOWER function requires a single string data type.
You've passed a number data type, thus it is returning an error.

If you rewrite that test like this:

IF(
    AND(
        5 = 6,
        LOWER("50")
    ),
    "ok",
    "not okay"
)

Then it should return "not okay" like you're expecting because 5 = 6 evaluates to false, and the LOWER("50") evaluates true due to the presence of the string.

I'm happy to dig further into the syntax and function behaviors if you're curious to get into the details a bit more.

I think that @Partyborn’s issue is a little subtler than that. In other programming languages, the computer will stop evaluating expressions as soon as it can determine if the whole expression is true or false. Thus the error would not occur because the computer would stop evaluating after the first argument was evaluated.

I wouldn’t exactly call this a bug. It is unpublished behavior that probably won’t be changed any time soon. However, feel free to report it directly to support.

The Airtable formula language is its own language. While many aspects are similar to other computer languages, it still has its differences, and those unexpected differences can trip is up.

Meanwhile, I not sure why it matters if all the parameters of an AND() function are always evaluated or not. It could have some performance impacts, but other than that, it is best to write formula such that the inputs will always be the correct type.

Partyborn
6 - Interface Innovator
6 - Interface Innovator

Im aware that lower does not accept and integer as parameter. It is just a simple example to reproduce the issue. Think of it that I am checking if it is an int in the first and condition. That is the usual way to do it in code. To me this seems like a bug.