### Google Spreadsheets IF Function Overview

As with Excel's IF function, Google Spreadsheet IF function allows you to use decision making in a worksheet. The IF function tests to see if 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 all set with the function's arguments.

In addition, multiple IF functions can be nested inside of each other to test multiple conditions and to carry out multiple operations depending on the outcome of the tests.

### The IF Function's Syntax and Arguments

A function's syntax refers to the layout of the function and 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 - (required) a value or expression that is tested to see if it is true or false;
- then_true - (required) the operation that is carried out if the
*test*is true; - otherwise_value - (optional) the operation that is carried out if the
*test*is false.

*Note:* When entering the IF function, the three arguments are separated by commas ( **,** ).

### Example Using the Google Spreadsheet IF Function:

As shown in the image above, the IF function is used to return various results such as:

=if(A2=200,1,2)

shown in row 3 of the example.

What this example does is:

- test to see if the value in cell A2 is equal to
*200*; - If it does, the function displays the value 1 in cell B3
- If A1 does not equal to
*200,*the function displays the value 1 in cell B3

### Entering the IF Function

Google Spreadsheets does not use dialog boxes to enter a function's arguments as can be found in Excel.

Instead, it has an *auto-suggest* box that pops up as the name of the function is typed into a cell.

### Entering the IF Function's Arguments

- Click on cell B3 to make it the active cell - this is where the results of the IF function will be displayed
- Type the equal sign ( = ) followed by the name of the function
*if* - As you type, the
*auto-suggest*box appears with the names of functions that begin with the letter "I"; - When the name
*IF*appears in the box, click on the name with the mouse pointer to enter the function name and opening parenthesis or round bracket into cell B3; - Click on cell A2 in the worksheet to enter that cell reference;
- After the cell reference, type the
*equal*symbol (**=**) followed by the number*200;* - Enter a comma to complete the
*test*argument - Type 2 followed by a comma to enter this number as the
*then_true*argument; - Type 1 to enter this number as the
*otherwise_value*argument - do not enter a comma; - Type to complete the function's arguments
- Press the
*Enter*key on the keyboard to enter a closing parenthesis "**)**" and to complete the function; - The value 1 should appear in cell A2, since the value in A2 does not equal 200;
- If you click on cell B3, the complete function =if(A2=200,1,2) appears in the formula bar above the worksheet.