OBJECTIVE OF THE CLASS
Know the logical function IF(), which allows situations and results to be analyzed in order to draw conclusions automatically, mainly based on a comparison operation.
INTRODUCTION LOGIC IN FUNCTIONS
As we have already told you, until today we have worked with the tools that give us results, such as those of a formula, function, filters, ordering, graphs, etc. Once we have these results, it is up to us to draw conclusions. For example, if I saw low grades on my report card, you concluded that I am at risk of failing. This is logical reasoning.
Among the functions of a spreadsheet there is a classification called Logical Functions, which do this type of "analysis and conclusion" work, and which are based on the comparison operations that you learned last week.
IF() FUNCTION
This is the first of the functions classified as logical. As will be stated in the introduction, this function will use a compare operation to "decide" which result to return. For example, look at this table with the temperature taken by several people:
The following example uses the IF() function to decide whether to return the word HEALTHY or SICK.
As you can see, the function will respond with whThe =IF function in Google Sheets is used to evaluate a condition. That is, when placing a logical test in the spreadsheet and entering the conditional formula, it will give you two results that can be “True” or “False” as appropriate.
These answers may vary depending on what you put in the syntax. For example, “Affirmative” or “Negative”, “Correct” and “incorrect”, etc. at you program, but it will still depend on the result of the comparison operation.
Syntax of the IF Function
The formula for the conditional If function in Google Sheets is as follows:
=IF(condition;value_if_true;value_if_false)
Remember that when starting a formula in Spreadsheets, you must always place the sign (=) before it. In the space where the condition is located, it is necessary to place the logical proof, for example “A>B”, “A<B”, etc.
With respect to the space where it says “value_if_true” or “value_if_false”, the response will be conditional on the initial condition. In other words, if the condition is correct, “True” will appear, otherwise “False” will appear.
If you want to modify the response words, this is possible by replacing “value_if_true” or “value_if_false” with the answers you want to receive. For example:
=IF(A5<8,”APPROVED”,”FAIL”)