Returns true if any argument is true and returns false if all arguments are false. ✅ Đã Test
Mẹo Hướng dẫn Returns true if any argument is true and returns false if all arguments are false. 2022
Bùi Nam Khánh đang tìm kiếm từ khóa Returns true if any argument is true and returns false if all arguments are false. được Cập Nhật vào lúc : 2022-11-26 19:25:08 . Với phương châm chia sẻ Mẹo Hướng dẫn trong nội dung bài viết một cách Chi Tiết Mới Nhất. Nếu sau khi Read tài liệu vẫn ko hiểu thì hoàn toàn có thể lại Comments ở cuối bài để Admin lý giải và hướng dẫn lại nha.Bottom Line: Learn how to use the IF Function to write formulas that return results based on a condition or logical test. This post includes training on logical tests, comparison operators, nested IF formulas, multiple conditions with AND and OR functions, and common causes of formula errors.
Nội dung chính Show- Watch the TutorialDownload the Excel FileMastering the IF FunctionLogical TestsReturning Other ValuesGrouping DataMultiple Logical TestsThe AND FunctionThe OR FunctionNested IF FormulasAlternative 1: The IFS FunctionAlternative 2: Lookup FormulasCommon Errors with the IF FunctionRelated PostsWhich formula returns TRUE if any argument is true?Which function returns true when the argument is false and if the argument is true then it returns false?Is a logical function that checks all the arguments and returns true if all are arguments are met?Which logical test returns true if all of its arguments are true?
Skill Level: Beginner
Watch the Tutorial
[embed]https://www.youtube.com/watch?v=EdluePUJbAQ[/embed] Watch on YouTube & Subscribe to our Channel
Download the Excel File
You can access the file that I use in the video by clicking below.
IF Function Explained.xlsxMastering the IF Function
The IF Function is an important function to know. It can help with comparing data, performing lookups to group data, and making reports interactive. If you're not familiar with IF or could use a refresher, this post will help.
Here is the IF function's signature:
=IF(logical_test, [value_if_true], [value_if_false])
The IF Function has 3 arguments:
Logical test. This is where we can compare data or see if a condition is met. Value if true. Defining this argument tells Excel to return a certain value if the condition in the logical test is met.Value if false. If the condition is not met, this argument defines what the returned value will be.Here's an example. I'm comparing Revenue amounts with Goal amounts. If the Revenue is greater than or equal to the goal, I want column D to say Yes, and if not, to say No.
Let's talk about the most important part of the IF function: the logical test.
Logical Tests
The logical test portion of the formula always uses a comparison operator to compare values and determine if the statement is true or false. Here is a list of comparison operators that can be used.
OperatorDescription= Equal To <> Not Equal To > Greater Than < Less Than >= Greater Than or Equal To <= Less Than or Equal ToLogical tests return TRUE or FALSE values. This is important because the logical test argument within IF needs a TRUE or FALSE (boolean) value returned to it. It is also important because you might not even need an IF function if the TRUE/FALSE values can be used to get the answer you are looking for.
It's also important to note that the case doesn't matter when comparing text. The following formula will return TRUE.
=”Excel Campus” = “excel campus”
Returning Other Values
While “TRUE” and “FALSE” would probably be sufficient for my example, I prefer them to say “Yes” and “No” in answer to the question in by column header: “Hit goal?”.
The advantage of using an IF function is that you can return any values you like by specifying the words that you want to appear. Just make sure to wrap them in quotation marks when writing your IF formula, unless they are numbers. If you do not specify these second and third arguments when writing the IF formula, it will simply return TRUE and FALSE.
The value_if_true and value_if_false arguments can contain just about anything:
- A numberText wrapped in double quotes – “hello”A reference to another cell – A2A
formula with another IF function.A formula with any other combination of functions.
It's also important to note that both the value_if_true and value_if_false arguments are optional. This is denoted by the square brackets around them in the function signature.
You must specify least one of the arguments. If you leave one of the arguments blank and the logical test results in that condition, then a TRUE or FALSE value will be returned to the cell.
For example, the following formula will return a FALSE if A2 does NOT equal B2 because the value_if_false argument is not specified.
=IF(A2=B2, "Match")
Grouping Data
One common use for the IF Function is to categorize data. Let me show you an example.
On this worksheet, I want to categorize transactions as either Large or Small depending on the amount I've entered in cell D4. A transaction less than $60,000 will be labeled as small. Transactions greater than or equal to $60,000 will be large.
When writing the formula, I could specify the amounts and the labels by typing them out, but I prefer to use cell references so that they can quickly and easily be updated without rewriting the formulas.
The dollar symbols ($) in the formula make the references absolute so that they don't change when the formula is copied down to the cells below it. When the cell reference within the formula is selected, you can hit F4 on your keyboard (for Fn + F4 for most máy tính keyboards) to insert a dollar symbol before the row number and column letter. (Pressing it repeatedly will toggle it to one or the other and back again to none or both.)
Categorizing these transactions is helpful for analyzing the data. You can filter out just the large or small items, or you can use these labels in a summary report, pivot table, or chart. Below is an example.
Multiple Logical Tests
If we want to use more than one logical test, we can use the AND and OR Functions.
The AND Function
The AND Function checks whether all arguments are true and returns TRUE if they are.
In the example below, our formula is looking for transactions that are both “Large” and “Product 6.”
The OR Function
Perhaps you want show a positive result if only ONE of the logical tests in your formula is true, not BOTH. If that is the case, you can use the OR Function.
The OR Function checks whether any of the arguments are true, and returns TRUE or FALSE. It returns FALSE only if all arguments are false.
Using the same sheet as above, the formula in our example below is looking for entries where the size is “Large” OR if the product name is “Product 5.”
If we want to return text or a number instead of TRUE or FALSE, then we can wrap the AND or OR Functions in the IF Function. For example, using the OR Function above as our logical test in an IF Formula, we can type the word Upgrade (in parentheses) as our Value If True argument. That means, when the conditions we've specified are true, the cell will say Upgrade. To return a blank cell when the conditions aren't met, we just have two quotation marks with nothing between them for our Value If False argument.
Nested IF Formulas
Things can get more complicated when there are more categories added to the mix. Maybe you want to group data based on 3 or more logical tests in your IF formula.
When this happens, we end up nesting another IF Function into our existing function each time we add another category.
For example, let's say we have three account categories called Small, Large, and Key. A Small account is less than $10,000. A Large account is between $10,000 and $70,000. And a Key account is more than $70,000.
When we write our formula to categorize these accounts, we will need to use two IF statements, with one nested within the other.
The logic of the formula goes like this.
If the amount is greater than or equal to $70,000, return a value of “Key.”But if it's NOT, evaluate the next IF Function.If the amount is greater than or equal to $10,000, return a value of “Large.”But if it's NOT, return a value of “Small.”With the cell references plugged in for the sizes and amounts, the formula would look like this on our spreadsheet.
As you can imagine, these nested IF formulas can get longer and uglier with each additional category or criteria that is added. That being the case, there are a couple of alternatives that I would like to mention.
Alternative 1: The IFS Function
This is a relatively new function introduced in Excel 2022. While it still requires a lot of selection and logical tests, it is somewhat easier to read and write the IFS formula compared to nested IF formulas.
I won't go into detail about writing the IFS Function, but you can play around with it in the Excel file attached the top of this post.
Alternative 2: Lookup Formulas
You can use VLOOKUP, XLOOKUP, or Index Match to return the same results as the nested IFs. These are a lot simpler to write. For an explanation of how to write a VLOOKUP formula like this, jump over to this tutorial:
How to Use VLOOKUP to Find the Closest Match – Last Argument is TRUE
Common Errors with the IF Function
If you come across errors when using the IF Function, it is most likely related to data types. What I mean by that is, Excel can't compare text to a number or a date, or evaluate text that is different. However, the formatting of values doesn't hinder Excel from making comparisons in logical tests. Below you can see how the values in Column A and Column B return a TRUE or FALSE in column C when they are compared.
Note that while the entry in B9 looks like it is formatted as a date, it is formatted as text. That is why it is returning FALSE when compared to the date in A9. See the video above for a further explanation on errors with data types.
Related Posts
If you found this information helpful, check out these other tutorials on related content.
- How to Calculate Commissions in Excel with VLOOKUP, XLOOKUP, or IFIntroduction to Pivot Tables and DashboardsExcel Tables Tutorial Video – Beginners Guide for Windows & Mac
Conclusion
Ready for a challenge? Test what you've learned and get more practice by taking our không lấy phí IF Formula Challenge! You can access it here:
The challenge includes videos that explain the challenge and walk through the solution. See if you can earn all six gold stars in the challenge file.
I hope this explanation has been helpful and that you start putting the IF Function to work in your spreadsheets soon if you're not already using it. Leave a comment below if you have questions or feedback!