{"id":1090,"date":"2010-09-07T14:31:00","date_gmt":"2010-09-07T06:31:00","guid":{"rendered":"http:\/\/vm-officeblogs.cloudapp.net\/2010\/09\/07\/true-or-false-if-provides-the-answer\/"},"modified":"2022-06-30T09:24:25","modified_gmt":"2022-06-30T16:24:25","slug":"true-or-false-if-provides-the-answer","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/09\/07\/true-or-false-if-provides-the-answer\/","title":{"rendered":"True or false, IF provides the answer"},"content":{"rendered":"
Today\u2019s post is brought to you by Frederique Klitgaard. Frederique is a writer on Office.com<\/p>\n
It\u2019s easy to understand why the IF function appears in the top 10 list of popular Excel functions. It\u2019s a versatile function that can be used for all sorts of tasks.<\/p>\n
For example, this function can save you a lot of time when you need to grade a stack of papers. It quickly turns a long list of test scores into grades without having to do any of the math. It can also instantly determine who passed or failed.<\/p>\n
I don\u2019t ever grade papers but I\u2019ll use this example to show you the effectiveness of this function. Let\u2019s start by having a look at the syntax that this function uses to determine that a condition is true or false.<\/p>\n
The first argument, logical_test<\/b>, is the required value or expression that will be evaluated to true or false. Expressions use comparison operators, such as equal to (=) or greater than (>), for example A10=100. For a list of comparison operators, see Calculation operators and precedence<\/a>.<\/p>\n The other two arguments, value_if_true<\/b> and value_if_false<\/b>, are optional arguments (as indicated by the square brackets in the syntax). When these arguments are used in the formula, they\u2019ll return the value that you want to be displayed when the logical_test<\/b> argument evaluates to true or false.<\/p>\n I\u2019ll apply this syntax to the following list of test scores.<\/p>\n To determine who passed or failed the test, I want the formula to return the following results:<\/p>\n In the first cell of the Result column, cell C2, I\u2019ll enter the following formula:<\/p>\n To turn the list of test scores into grades, I can go a step further and embed additional IF functions as formula arguments, often referred to as nesting. You can nest up to 64 IF functions as value_if_true<\/b> and value_if_false<\/b> arguments.<\/p>\n I want the formula to return the grades as follows:<\/p>\n Based on these conditions, the nested formula I\u2019ll enter in the first cell of the Grade column, cell D2, will then look like this:<\/p>\n Notice that I\u2019ve nested three other IF functions to calculate the grades. The last argument doesn\u2019t need the IF function; it automatically displays an F for numbers that have not been accounted for in the nested IF functions. I\u2019ve used the IF function four times, so I\u2019ll need to include four ending parentheses in the formula.<\/p>\n\n\n
\n Student<\/td>\n Test Score<\/td>\n Result<\/td>\n Grade<\/td>\n<\/tr>\n \n Student 1<\/td>\n 35<\/td>\n <\/td>\n <\/td>\n<\/tr>\n \n Student 2<\/td>\n 67<\/td>\n <\/td>\n <\/td>\n<\/tr>\n \n Student 3<\/td>\n 88<\/td>\n <\/td>\n <\/td>\n<\/tr>\n \n Student 4<\/td>\n 70<\/td>\n <\/td>\n <\/td>\n<\/tr>\n \n Student 5<\/td>\n 95<\/td>\n <\/td>\n <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \n\n
\n Test score<\/b><\/td>\n Result<\/b><\/td>\n<\/tr>\n \n Greater than or equal to 70<\/b><\/td>\n Passed<\/td>\n<\/tr>\n \n Less than 70<\/b><\/td>\n Failed<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n IF(B2>=70, \u201cPassed\u201d, \u201cFailed\u201d)<\/h2>\n
\n\n
\n Test score<\/b><\/td>\n Grade<\/b><\/td>\n<\/tr>\n \n Greater than 89<\/b><\/td>\n A<\/td>\n<\/tr>\n \n From 80 to 89<\/b><\/td>\n B<\/td>\n<\/tr>\n \n From 70 to 79<\/b><\/td>\n C<\/td>\n<\/tr>\n \n From 60 to 69<\/b><\/td>\n D<\/td>\n<\/tr>\n \n Less than 60<\/b><\/td>\n F<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n IF(B2>89, \u201cA\u201d, IF(B2>79, \u201cB\u201d, IF(B2>69, \u201cC\u201d, IF(B2>59, \u201cD\u201d, \u201cF\u201d))))<\/h2>\n