# How to Use the Google Sheets If( ) Function

## Using the If( ) formula for logical functions

As with Excel's If( ) function, the If () function in Google Sheets facilitates branched decision-making within a worksheet. The If( ) function tests whether a certain condition in a cell is true or false.

• If the condition is true, the function will carry out one operation.
• If the condition is false, the function will carry out a different operation.

The initial true or false test, as well as the follow up operations, are set with the function's arguments.

Nest If( ) statements to test several conditions and to carry out different operations depending on the outcome of the tests.

## The If( ) Function's Syntax and Arguments

A function's syntax refers to the format in which the function must be stated. It includes the function's name, brackets, comma separators, and arguments.

The syntax for the If( ) function is:

`=if(test, then_true, otherwise_value)`

The function's three arguments are:

• Test: a value or expression that is tested to see if it is true or false
• Then_true: the operation that is carried out if the test is true
• Otherwise_value: the operation that is carried out if the test is false

The otherwise_value argument is optional, but you must specify the first two arguments for the function to process correctly.

## Example of the Google Sheets If( ) Function

In row 3, the If() function returns various results such as:

`=if(A2=200,1,2)`

This example:

• Tests to see if the value in cell A2 is equal to 200 (the test argument)
• If it does, the function displays the value 1 in cell B3 (the then_true argument)
• If A1 does not equal 200, the function displays the value 2 in cell B3 (the optional otherwise_value argument)

If you decline to enter an otherwise_value argument, Google Sheets will return the logical value false.

## Entering the If( ) Function

Unlike Excel, Google Sheets does not use dialog boxes for function arguments. Instead, it has an auto-suggest box that pops up as you type the name of the function into a cell.

To enter the function:

1. Click cell B3 to make it the active cell

2. Type the equal sign ( = ) followed by the name of the function if.

3. As you type, the auto-suggest box appears with the names of functions that begin with the letter I.

4. When IF appears in the box, click it to enter the function name and opening parenthesis or round bracket into cell B3.

5. Click cell A2 in the worksheet to enter that cell reference.

6. After the cell reference, type the equal symbol (=) followed by the number 200.

7. Enter a comma to complete the test argument.

8. Type 2 followed by a comma to enter this number as the then_true argument.

9. Type 1 to enter this number as the otherwise_value argument. Do not enter a comma.

10. Complete the function's arguments.

11. Press Enter to insert a closing parenthesis ) and to complete the function.

12. The value 1 should appear in cell A2, given that the value in A2 does not equal 200.

13. If you click cell B3, the complete function appears in the formula bar above the worksheet.