As with Excel's If() function, the If() function in Google Sheets facilitates branched decisionmaking 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 all 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 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: 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:
The If() function returns 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 (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
Google Sheets does not use dialog boxes to enter a function's arguments as can be found in Excel. Instead, it has an autosuggest box that pops up as the name of the function is typed into a cell.
To enter the function:

Click cell B3 to make it the active cell.

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

As you type, the autosuggest box appears with the names of functions that begin with the letter I.

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

Click 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.

Complete the function's arguments.

Press the Enter key on the keyboard to insert 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 cell B3, the complete function
=if(A2=200,1,2)
appears in the formula bar above the worksheet.