# IF

Formulas / IF
To test a condition and return one value if the condition is true and another value if the condition is false.
`IF(logical_test, value_if_true, [value_if_false])`
• logical_test - the condition to test
• value_if_true - the value to return if logical_test is TRUE
• value_if_false - the value to return if logical_test is FALSE
• NOTE: One of value_if_true or value_if_false must be specified

## Examples

• `=IF(A1>70,"Pass","Fail") // returns "Pass" for scores above 70`

This example returns "Pass" if the value in A1 is greater than 70. If the value in A1 is less than or equal to 70, the function returns "Fail".

• `=IF(C5>=70,"Pass","Fail") // returns "Pass" if C5 is greater than or equal to 70`

This example returns "Pass" if the value in C5 is greater than or equal to 70. If the value in C5 is less than 70, the function returns "Fail".

• `=IF(C5<70,"Fail","Pass") // returns "Fail" if C5 is less than 70 and returns "Pass" if not`

This example returns "Fail" if the value in C5 is less than 70. If the value in C5 is greater than or equal to 70, the function returns "Pass".

• `=IF(B5="red",100,IF(B5="blue",125)) // returns 100 if B5 equals "red" else returns 125 if B5 equals blue`

This example returns 100 if the value in B5 is "red". If instead the value in B5 is "blue", then this example returns 125.

## Summary

The IF function is a popular Sourcetable function that allows you to compare a value with what you expect that value to be.

• The logical value IF returns is determined by the value of the logical_test argument.
• IF may return either a value, a cell reference, or another formula.
• The logical_test argument must in IF return either TRUE or FALSE
• The value_if_true and value_if_false arguments of IF are optional, but at least one of them must be provided.
• IF is not case-sensitive.
• It is easier to use COUNTIF or COUNTIFS to count values conditionally than using IF with other functions.
• It is easier to use SUMIF or SUMIFS to sum values conditionally than using IF with other functions.
• IF evaluates each array element if an argument is supplied as an array.

## Frequently Asked Questions

What is the IF function?
The IF function is one of the most popular Sourcetable function. It can evaluate both text and values, and return more than one result. It can be used with additional mathematical operators, and can be nested to perform multiple comparisons.
Can I use text with the IF function?
Yes, text may be used with the IF function if the text is wrapped in quotes.
What are some advanced IF functions?
Advanced IF functions include COUNTIF, COUNTIFS, SUMIF, SUMIFS.
How can the IF function be used?
The simplest way to use IF is for evaluating text or values. However, the IF function can be used with additional mathematical operators and can be nested to perform multiple, complex comparisons.