# Logical Functions - IF, IFERROR, AND, OR

### What is a Logical Function?

It is a feature that allows us to introduce decision-making when executing formulas and functions. Functions are used to;

* Check if a condition is true or false
* Combine multiple conditions together



**What is a condition and why does it matter?**

A condition is an expression that either evaluates to true or false. The expression could be a function that determines if the value entered in a cell is of numeric or text data type, if a value is greater than, equal to or less than a specified value, etc.



**IF**

The IF function can perform a logical test and return one value for a TRUE result, and another for a FALSE result. For example, to "pass" scores above 70: =IF(A1>70,"Pass","Fail"). More than one condition can be tested by nesting IF functions. The IF function can be combined with logical functions like AND and OR.

> &#x20;**=IF(logical\_test, \[value\_if\_true], \[value\_if\_false])**



**IFERROR**

Returns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula. Use the IFERROR function to trap and handle errors in a formula.

> **=IFERROR(value, value\_if\_error)**



**AND**

The AND function is a logical function used to require more than one condition at the same time. AND returns either TRUE or FALSE. To test if a number in A1 is greater than zero and less than 10, use =AND(A1>0,A1<10). The AND function can be used as the logical test inside the IF function to avoid extra nested IFs, and can be combined with the OR function.

> **=AND(logical1, \[logical2], ...)**



**OR**

The OR function is a logical function to test multiple conditions at the same time. OR returns either TRUE or FALSE. For example, to test A1 for either "x" or "y", use =OR(A1="x",A1="y"). The OR function can be used as the logical test inside the IF function to avoid extra nested IFs, and can be combined with the AND function.

> **=OR(logical1, \[logical2], ...)**





{% file src="https://2721809844-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR_tHSREe3Wm40fY9NG%2F-LRuFRq01Rtp-nSXiZGN%2F-LRuHT3zYleQ2Y9Bc0gW%2FIFERROR.xlsx?alt=media&token=e3328691-aafb-41ac-9d03-4960a1a0d6bd" %}
Iferror Formula Example Sheet
{% endfile %}

{% file src="https://2721809844-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LR_tHSREe3Wm40fY9NG%2F-LRuFRq01Rtp-nSXiZGN%2F-LRuHaP3j2XshBVsJyn7%2FLogical%20Functions%20-%20IF%2C%20AND%2C%20OR.xlsx?alt=media&token=bb13b98f-b611-4850-8033-a3a55842c25b" %}
If, AND, OR Example sheet
{% endfile %}
