Ninja Excel BlogExcel formulas and functionsYES function: Manage it perfectly in 4 steps

YES function: Manage it perfectly in 4 steps

I work on a computer

​The function YEAH Excel is one of the most used functions since it tests whether a condition is met or not. In this article you will quickly learn how to use it.

Key information:

This function allows you to evaluate a condition. Excel checks if the logical test is met and delivers different results. The first result is delivered when the evaluation is true, the second if it is false.  

How does it work?

  • Purpose: The IF function allows us to evaluate whether a condition is true or false. If true, it performs a given action, otherwise it performs another action. 
  • Characteristics:It allows you to evaluate with different symbols, for example, equal, less, greater than or equal, unequal, etc. Numeric or text values can also be evaluated in the logic test.
  • Syntax:​​​​​​ =IF(logical_test; [value_if_true]; [value_if_false]
  • Arguments:
    • logical_test: Value or expression that we seek to evaluate.
    • value_if_true: Value returned when the evaluation is true. This value can be text, calculations, a reference to another cell, or other functions.
    • value_if_false: Value returned when the evaluation is false. This argument is optional, if not set, Excel will respond “FALSE” automatically.

Step 1: Understanding the IF function

The Excel IF function is used in different situations. It allows you to verify logical tests by delivering different values if it is true or false. To understand better, let's look at the diagram,

Schematic showing how the Excel IF function works. Shows the logical test and the answers it can deliver.

Excel will check the condition, delivering a different result in each case. Logical tests and results can be numerical values, texts, mathematical operations, or formulas.

We recommend the following video to understand how SI works.

Step 2: Using the IF function

Evaluating numerical conditions

The formula allows you to verify numerical tests. When we have text arguments we must write it in quotes. For example, the formula can be used to categorize people into majors and minors.

Example table for the Excel IF function that shows the results we are looking for.

Excel evaluates whether you are of legal age by providing a response “Of Legal Age”, if your age is greater than or equal to 18 years, and “Minor”, if your age is less. 

Excel IF function example table. Shows how it works and also specifies the formula that is used

The elements of the function are:

  • logic_test:  C3>=18
  • value_if_true: “Adult"
  • value_if_false:  "Younger"

That is, the IF function is:

Formula that uses the Excel IF function. Show how the formula works in the given example.

What it means is: “If Sofia's age is greater than or equal to 18, the IF function responds Adult, otherwise, respond Younger

The result we will obtain will be:

Table showing the answer obtained from the IF function in the given example.

We can verify that Sofia's age is 18 years old, and since it is equal to 18, it is adult, agreeing with the answer.

We do this for all people:

Explanatory table of the Excel IF function. Show how the formula works in a given example.

Evaluating text conditions

The IF function also evaluates text logistic tests. Continuing with the example, we want the adult category to get a discount. 

Example table of how to use the Excel IF formula with texts included in the logical test.

Excel evaluates the age category, responding Yeah, if you are of legal age or responding No, if it doesn't match.  

Table illustrating the example of how to use the Excel IF function. Shows what the formula is like when we perform the IF function with texts.

Therefore, the elements that the function will have are:

  • logic_test:  D3=”Of Age”
  • value_if_true:  Yeah
  • value_if_false:  No

That is, the IF function is:

Illustrates what the Excel IF function formula looks like. Shows the syntax of the IF function.

What it means is: “If Sofia's age category is Adult, the IF function responds Yeah, otherwise, respond No

The result we will obtain will be:

Table showing how the Excel IF formula works. The example is the IF function when evaluating a logical text test.

Step 3: Combine the IF function with the OR and AND functions

By using the IF function in conjunction with the OR and AND formulas you will become a true Excel Ninja. 

To combine them correctly, we must include these functions in the logical test of the IF formula. Continuing with the example, if a person's age is between 20 and 40 years old, they will be given a discount. We use the AND function.

Table showing an example of how to use the Excel IF function. In this example we combine the IF function with the AND function.

Therefore, the elements that the function will have are:

  • logic_test:  Y(C3>20; C3<40)
  • value_if_true:  Yeah
  • value_if_false:  No

That is, the IF function is:

Formula that we use for the example of the IF function combined with the Excel IF function.

What it means is: “If Sofia's age is greater than 20 and less than 40 years old, the SI function responds Yeah, otherwise, respond No

The result we will obtain will be:

Table showing the example of how to combine the Excel IF function with the Excel AND or OR functions. This table shows the final result of this combination.

Ninja Tip: Visit the following article to delve deeper into the combination of IF and AND functions.

Step 4: Nested IF Function

Nested IF function is used when we need to evaluate more than one logical test and get more than two answers. For this, we have to add an IF function, inside the main IF formula. The schematic shows how it works.

Schematic showing how Excel's nested IF function works. It shows us how, from the logical test, Excel delivers one answer when it is true and another when it is false.

In the event that logical test 1 is satisfied, Excel responds TRUE. In the event that it is not met, Excel will evaluate the second logical test and depending on whether it is met, it returns TRUE or FALSE.  

In the example, we want to add the elderly category. We consider a senior citizen when their age is greater than or equal to 65 years.

Table that shows an example of how the nested Excel SI formula works, the table shows us the answers we are looking for.

Therefore, the elements that the function will have are:

  • logic_test:  C3>=65
  • value_if_true:  “Third age”
  • value_if_false:  IF function:
    • Logic test:  C3<18
    • value_if_true:  "Younger"
    • value_if_false:  "Adult"

That is, the IF function is:

Formula that demonstrates how the nested function works, including two logical tests and three different answers.

What it means is: “If Sofia's age is greater than or equal to 65, the IF function responds Third Age, otherwise, the second logical test will be evaluated, which consists of: if Sofia's age is less than 18, answer Younger, otherwise, respond Adult

Table that shows how the Excel IF formula works, the table gives us the answers we are looking for.

Ninja Tip: When we want to perform many logical tests, using the nested IF function can be very complicated, so we recommend using the IF.SET formula that allows you to perform up to 127 logical tests.

Common mistakes

*IF function answers 0

On some occasions it may respond with a “0”. This error usually indicates that a value was not defined for the true and false arguments. 

If this happens to you, we recommend giving value to the true and false arguments.

* #NAME?

This error usually indicates that there is an error in the formula. We advise you to review the following points:

  • Check that the text values for true and false are in quotes.
  • Make sure the logical proof is set up correctly.
Table that shows common errors when using the Excel IF function. There are two common errors: that the IF function returns a zero, or that it responds #NAME?

Ninja Tip:  You can use the IF.ERROR or IF.ND functions to handle errors.  

Frequent questions

How to use the yes function in Excel for passed and failed?

For this we can use the function as follows: =IF(A2>=70,”PASSED”,“FAIL”) in this case A1 would be where the grade appears

How many arguments does the yes function have?

The Yes function has 3 arguments: Logical test, value if true and value if false.

What is a nested yes function?

Nested IF function is when we add a second IF function inside the first one. In this way you can test some more conditions.

Fernanda is a strategy and development analyst, she trained as a commercial engineer at the Universidad Católica de Chile and also as a mathematics professor at the Universidad de los Andes.

white ninja excel logo

The leading Excel training platform for companies.

Company

Copyright © 2024 Ninja Excel.

English