In Google Sheets, the 'IF' function authorizes you to check a condition and return a value when it's TRUE.
For example, you have three columns in a Google Sheet: profit, channel, and target. Now you want to know which channel has higher profit than the target.
Use the IF function in Google Sheets – the formula would look "YES" when the target is higher than the profit, and if not, it will return a "NO." You can track that data from another column named "Goal Met."
Utilizing the "IF" Function in Google SheetsWhen using the "IF" function in Google Sheets, use the following syntax:
IF(logical_expression, value_if_true,value_if_false)Explanation of each syntax:
Logical_expression refers to the condition you're reviewing the function.
Value IF true is the value that will return when the logical expression is true.
Value IF false is the value that will return when the logical expression is false.
To do this, you've to use the following expression symbols:
> to symbolize greater than
>= to symbolize equal or greater than
< to symbolize greater than
<= to symbolize equal or less than
<> to symbolize not equal
= to symbolize equally
Here's an example of how using the IF function in Google Sheets works in real-life scenarios.
Example 1: Single Condition with If Function
Suppose you have students' marks in an exam and want to determine whether a student has failed or passed.
You can find this out with the help of the "IF" function in Google Sheets.
Use the formula:
=IF(B2>35,"Pass","Fail")
It checks when the score exceeds 35 or not. If it is, it returns Pass, or else it returns Fail.
Example 2: Multiple Conditions with IF Function
Using the above example, if you want to assign a grade based on the marks obtained.
For instance, a student gets an F grade if they score less than 35, D between 35 and 50, C for a score between 50 and 70, a B for a score between 70 and 90, and an A for more than 90
In this case, you not only have to check if the mark is above 35 or not but also examine the range in which it lies.
Here is the formula that gives you the result in this case:
=IF(B2<35,"F",If(B2<50,"D",If(B2<70,"C",If(B2<90,"B","A"))))
This formula checks if the score is less than 35 or not. When it is, it returns F, moves on to the next condition, and so on.