• Account
• API
• Integrations
• Enterprise
• Resources
Catching errors with logical functions
• 04 Oct 2022
• 2 Minutes to read
• Dark
Light

# Catching errors with logical functions

• Dark
Light

Formulas provide so many possibilities that, by nature, some of those possibilities will result in an error. Fortunately, with the help of logical functions, you can catch those errors and present something more useful in their place. In this article, we’ll cover different approaches to identifying and outputting errors in a formula field.

## `ERROR()`

`ERROR()` is a logical function that returns the error value. This means that you can output an error message - `#ERROR!`- by calling this function.

To show how this looks in an Airtable base, here is a formula field that only has
`ERROR()`written in the formula field.

## `ISERROR()`

`ISERROR() `returns "true" (represented by a 1) if the expression it references causes an error, or "false" (0) if there is no error. As an example, because you cannot divide a number by zero, this formula example would result as true:
`ISERROR({Price} / 0)`

This function can be helpful in identifying any type of error in a formula. In the screenshot below you'll see a couple of different errors showing in {Error Types} from the formula used.

In the formula field on the far right, using `ISERROR() `identifies that there is any type of error in the formula rather than outputting the particular one. You'll learn why this is useful in the next section!

## Errors and logical functions

This function can become even more useful when used in conjunction with an IF statement to output a warning or status whenever a formula results in an error. This could help you identify missing or incorrect values in another field, or display a generic message whenever there is any error found.

For example, let's say you have a formula to calculate gross profit margin:

``````{Net Sales} -  {Cost of Goods Sold} ) /  {Net Sales}
``````

In the screenshot above, an Infinity error is caused by a missing value in the net sales field. If you wanted to only run the gross profit margin formula whenever there was a value in {Net Sales}, you could write an IF statement like this:

``````IF(
{Net Sales},
({Net Sales} - {Cost of Goods Sold}) / {Net Sales},
BLANK()
)``````

However, this wouldn't account for other potential errors that could occur within the table (a missing value in {Cost of Goods Sold}, or a zero value in net sales, etc). Rather than the formula above - or a more complex IF statement to account for each potential error scenario - you could instead use this:

``````IF(
ISERROR(
{Gross Profit Margin}
),
)``````

Having a single text value (🚨 Alert) in this field could trigger a notification to a project manager so they can review, or filter in records into a view where someone can address any missing/incorrect values as needed).

Circling back to the ERROR() function, you could also use that in place of a customized message!

``````IF(
ISERROR(
{Gross Profit Margin}
),
ERROR()
)``````

 Formula FoundationsThis article is part of a guided course that helps you learn how to use Airtable formulas.