Thứ Sáu, Tháng Hai 7, 2025
spot_img
HomeSpecific IF function syntax and examples

Specific IF function syntax and examples

IF function in Excel is a condition function that is used quite a lot. Here it is Things you need to know about the If command in Excel.

The IF function in Excel is a basic Excel function and is widely used in Excel data tables for statistics. The IF function in Excel checks a condition and returns a value if the condition is met, or returns another value if the condition is not met. The following article will guide you how to use the IF function in Excel.

How to use the IF function in Excel

1. IF function formula in Excel

The IF function in Excel has the following syntax:

IF (logical_test, [value_if_true], [value_if_false]).

In there:

  • Logical_test: Conditional expression.
  • Value if true: Return value if the condition is true.
  • Value if false: Return value if the condition is false.

Note about the IF function in Excel:

  • If value_if_true is omitted in an IF formula, the IF function will return 0 if the main condition is met.
  • If value_if_false is omitted, the IF function will return the value FALSE.
  • If you want Excel formulas to display logical values ​​such as TRUE or FALSE when a certain condition is met, you must type TRUE in the value_if_true parameter box. The value_if_false box can be filled in as FALSE or left blank.

2. Example of using IF function in Excel

We will use the student's transcript below with the total score of 3 subjects and ask to enter pass or fail results according to each condition.

Student transcript

2.1. Basic IF function

Example 1:

According to this table If a student has a total score of 20 points or more in 3 major subjects, he or she will have a passing result. If a student has less than 20 points, he or she will fail..

We will have the calculation formula: = If(F2>20,”Pass”,”Fail”) then press Enter to display the results.

If function 1 condition

You will now see the results box showing Pass. We just need to fill the results of the first cell down to the remaining cells.

If function results 1 condition

Example 2:

Also in the statistics table, fill in the results If the student's total score is greater than 15 points and no score is below 0 points, the result will be classified as pass.

We enter the formula below and press the Enter button to execute.

= If(And(F2>15,C20,D20,E20),”Đỗ”,”Trượt”)

Basic if function

Immediately after that you will also see the results displayed in the cell where the formula was entered. We just need to drag the first result box down to the remaining boxes to pass or fail.

If function example

2.2 Nested IF function

Example 1: IF & AND function in Excel

The nested IF function is an AND combination when you will have to consider combining multiple conditions at the same time to get the result. Then we need to combine multiple IF functions in the same formula.

In the data table below, we will student classification Based on the average score of 3 subjects that the student achieves with the following conditions:

  • If the average score is greater than or equal to 8.5, it will be classified as good academic performance.
  • If the average score is greater than or equal to 6.5 and less than 8.5, the academic performance is considered good.
  • If the average score is greater than or equal to 5 and less than 6.5, rank average academic performance.
  • If the average score is less than 5, the student will be classified as weak academically.

If & and function example

We will have the formula as below and then press Enter.

=IF(E2>=8.5,"Giỏi",IF(AND(E2>=6.5,E2=5,E2

If & and function formula

You will immediately receive the rating results. We just need to drag the first result cell down to the remaining cells.

If & and function results

Example 2: IF & OR function in Excel

We have the example table below with 2 columns of student scores and results Graded as pass or fail if the student's score 1 is greater than or equal to 20 or score 2 is equal to or greater than 25.

If & or function results

We have the formula below and then press Enter.

=IF((OR(B2>=20, C2>=25)), “Đỗ”,“Trượt”)

If & or function formula

As a result, you will receive the rating of the first student and just scroll down to the box below.

If & or function results

Example 3: IF function combines AND and OR in Excel

We have the employee table below with requests to fill in different bonus levels. If Female employees in the Administration or Accounting departments will receive a bonus of 700,000 VNDthe In other cases, the reward is 500,000 VND.

If & and & or function results

We will have the formula as below and then press Enter.

=If(and(or(B2= “Hành chính”,B2= “Kế toán”), C2= “Nữ”), 700,500)

If & and & or function formula

As a result, you will immediately have bonuses for employees according to each requirement that we have stated.

If & and & or function results

How to fix IF function errors in Microsoft Excel

In some cases, the error you encounter is often due to using the IF function incorrectly, possibly arising from a formula or cell reference.

The first thing you should do is make sure you write your function with the correct structure, including punctuation. Additionally, the problem can also potentially arise from nested functions with IF. The key here is to understand the function you are using so you don't write it wrong or enter an invalid value.

Here are 4 common mistakes when using the IF function:

Error Describe
#DIV/0! Your formula is trying to divide a value by zero.
#VALUE! You entered the wrong data type into the formula. For example. The formula must contain numbers, but you use text.
#REF! Reference cells or formula cells have been moved. The references in the formula no longer exist.
#NAME? You entered the wrong function name in the formula.

You just need to determine where the error is when using it IF function in Excel it can be fixed easily.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments