Google Sheets IF | Tutorial | IF Google Sheets
HTML-код
- Опубликовано: 8 сен 2024
- The Google Sheets IF function helps you to test a logical expression. It will be either true or false. You can assign a value that this function should return if the expression is true and vice versa.
For example, let's assume there's a spreadsheet, which lists names of members of a club and their age. Say you want to give a
discount of ten percent on train fare if a person is a senior citizen. The IF function in Google Sheets is handy for the above task.
The format of the Google Sheets IF is:
=IF(logical_expression, value_if_true, value_if_false)
As you can see, the Google Sheet IF function is straight forward. The function starts with the mandatory equal-to symbol. The name of the function, which in this case is IF, follows. Next
to it is the opening parenthesis. The first attribute of the function is the logical expression. You then have to specify two values. Google Sheets uses the first value, if the expression evaluates to true. It uses the second value, if the expression evaluates to false.
Let's use the IF function Google Sheets for the above example. Let's assume that column A of the example worksheet has the names of the people and column B has either the text, senior citizen, if a member is a senior citizen, or has two dashes (--) if the member is less than age 60. Column C is titled Discount. Say that cells A1, B1, and C1 has the text Name, Age, and Discount respectively.
Before you type the Google Sheets IF, position the cursor in cell C2. Now, type the IF function:
=IF(B2="senior citizen", C2="10%", "--")
Press Enter.
If the Google Sheet IF function evaluates the expression to true, that is if cell B2 has the text, senior citizen, then cell C2 will have the value, 10%. If the function evaluates the expression to false, cell C2 will have two dashes (--).
How to apply the Google Sheet IF function to other cells? Position the cursor in cell C2. Drag down the blue square handle in the lower right till you include all the cells in column C. The IF function Google Sheets is copied to all the cells and their values are displayed instantaneously.
Use the filter function to remove any blank cells, between the cells with data, and create a contiguous list.
Take a look at this video, which is a tutorial on how to use the IF function Google Sheets. This function is illustrated with an example.