A logical test means having an analytical output that is either TRUE or FALSE. In Excel, we can perform a logical test for any situation. The most commonly used logical test is using the equals to the operator, which is “=” if we use =A1=B1 in cell A2, then it will return TRUE if the values are equal and FALSE if the values are not equal.
What is the Logical Test in Excel?
In Excel, at the beginning stages of learning, it is not easy to understand the concept of logical tests. But once you master this, it will be a valuable skill for your CV. More often than not, in Excel, we use a logical test to match multiple criteriaCriteria based calculations in excel are performed by logical functions. To match single criteria, we can use IF logical condition, having to perform multiple tests, we can use nested IF conditions. But for matching multiple criteria to arrive at a single result is a complex criterion-based calculation.read more and arrive at the desired solution.
In Excel, we have as many as 9 logical formulas. We must go to the “Formulas” tab and click on the “Logical” function group to see the logical formulas.
Some of them are frequently used formulas, and some of them are rarely used. This article will cover some of the important Excel logical formulas in real-time examples. All the Excel logical formulas work based on TRUE or FALSE if the logical test we do.
Table of contents
- What is the Logical Test in Excel?
- How to Use Logical Function in Excel?
- #1 – AND & OR Logical Function in Excel
- Example #1- AND Logical Function in Excel
- Example #2 – OR Logical Function in Excel
- #2 – IF Logical Function in Excel
- #3 – IF with AND & OR Logical Functions in Excel
- Things to Remember
- Recommended Articles
How to Use Logical Function in Excel?
Below are examples of logical functions in Excel.
You can download this Logical Functions Excel Template here – Logical Functions Excel Template
#1 – AND & OR Logical Function in Excel
Excel AND and OR functions work opposite each other. For example, AND condition in Excel requires all the logical tests to be TRUE. On the other hand, the OR function requires any logical tests to be TRUE.
For example, look at the below examples.
We have student names, marks 1, and marks 2. If the student scored more than 35 in both exams, the result should be TRUE. If not, the result should be FALSE. Since we need to satisfy both the conditions, we need to use AND logical test here.
Example #1- AND Logical Function in Excel
- We must open AND function first.
- The first logical 1 is Marks-1 is >35 or not to test the condition.
- The second test is Marks-2 is >35 or not. So, we must take the logical test.
- We have only two conditions to test. So, we have applied both the logical tests. Now close the bracket.
If both conditions are satisfied, the formula returns TRUE by default. Else, returns FALSE as a result.
Drag the formula to the rest of the cells.
In cells D3 and D4, we got FALSE because in “Marks-1,” both the students scored less than 35.
Example #2 – OR Logical Function in Excel
The Excel OR function is completely different from the AND function. The OR in ExcelThe OR function in Excel is used to test various conditions, allowing you to compare two values or statements in Excel. If at least one of the arguments or conditions evaluates to TRUE, it will return TRUE. Similarly, if all of the arguments or conditions are FALSE, it will return FASLE.read more requires only one condition to be TRUE. Therefore, we must apply the same logical test to the above data with OR conditions.
We will have results in either FALSE or TRUE. Here, we got TRUE.
Drag the formula to other cells.
Now, look at the difference between AND and OR functions. The OR function returns TRUE for students B and C even though they have scored less than 35 in one of the exams. However, since they scored more than 35 in Marks 2, the OR function found the condition of >35 TRUE in 2 logical tests and returned TRUE as a result.
#2 – IF Logical Function in Excel
The IF excel FunctionIF function in Excel evaluates whether a given condition is met and returns a value depending on whether the result is “true” or “false”. It is a conditional function of Excel, which returns the result based on the fulfillment or non-fulfillment of the given criteria.
read more is one of the important logical functions to discuss in Excel. It includes three arguments to supply. Now, look at the syntax.
- Logical Test: It is nothing but our conditional test.
- Value if True: If the above logical test in Excel is TRUE, what should be the result.
- Values if FALSE: If the above logical test in Excel is FALSE, what should be the result.
For example, take a look at the below data.
If the product’s price is more than 80, we need the result as “Costly.” On the other hand, if the product’s price is less than 80, we need the result as “OK.”
Step 1: Here, the logical test is whether the price is >80 or not. So, we must open the IF condition first.
Step 2: Now pass the logical test in Excel, Price >80.
Step 3: If the logical test in Excel is TRUE, we need the result as “Costly.” So in the next argument, VALUE, if TRUE, mentions the result in double-quotes as “Costly.”
Step 4: The final argument is if the logical test in Excel is FALSE. If the test is FALSE, we need the result to be “OK.”
We got the result of “Costly.”
Step 5: Drag the formula to other cells to have the result in all the cells.
Since the orange and sapota price is less than 80, we got the result as “OK.” However, the logical test in Excel is >80, so we got “Costly” for apples and grapes because their price is > 80.
#3 – IF with AND & OR Logical Functions in Excel
The IF function with the other two logical functions (AND & OR) is one of the best combination formulas in Excel. For better understanding, look at the below example data, which we have used for AND and OR conditions.
If the student scored more than 35 in both the exams, it would declare him a PASS or FAIL.
The AND function, by default, can only return TRUE or FALSE as a result. But here, we need the results as PASS or FAIL. So, we have to use the IF condition here.
Open the IF condition first.
If we can only test one condition simultaneously, we need to look at two conditions. So, we must open AND condition and pass the tests as Exam 1 >35 and Exam 2>35.
If both the supplied conditions are TRUE, we need the result as “PASS.” So mention the value “PASS” if the logical test in Excel is “TRUE.”
If the logical test in Excel is “FALSE,” the result should be “FAIL.”
So, here we got the result as “PASS.”
Drag the formula to other cells.
So, instead of default TRUE or FALSE, we got our values with the help of the IF condition. Similarly, we can also apply the OR function and replace the OR function with the IF and AND functions.
Things to Remember
- The AND functionThe AND function in Excel is classified as a logical function; it returns TRUE if the specified conditions are met, otherwise it returns FALSE.read more requires all the logical tests in Excel to be TRUE.
- The OR function requires at least any logical tests to be TRUE.
- We have other logical tests in Excel like the IFERROR function in excelThe IFERROR function in Excel checks a formula (or a cell) for errors and returns a specified value in place of the error.read more, NOT function in excelNOT Excel function is a logical function in Excel that is also known as a negation function and it negates the value returned by a function or the value returned by another logical function.read more, TRUE Function in excelIn Excel, the TRUE function is a logical function that is used by other conditional functions such as the IF function. If the condition is met, the output is true; if the conditions are not met, the output is false.read more, FALSE, etc.…
- We will discuss the remaining Excel logical tests in a separate article.
Recommended Articles
This article is a guide to Logical Tests in Excel. We discuss logical functions like AND, OR, and IF in Excel, practical examples, and a downloadable template. You may also learn more about Excel from the following articles: –
- SUMIF with Multiple CriteriaThe SUMIF (SUM+IF) with multiple criteria sums the cell values based on the conditions provided. The criteria are based on dates, numbers, and text. The SUMIF function works with a single criterion, while the SUMIFS function works with multiple criteria in excel.read more
- IFERROR in Excel VBAThe IFERROR function in Excel is used to determine what to do when an error occurs before performing any function.read more
- SUMPRODUCT in Excel with Multiple CriteriaIn Excel, using SUMPRODUCT with several Criteria allows you to compare different arrays using multiple criteria.read more
- VLookup Function with IFIn Excel, vlookup is a reference function, and IF is a conditional statement. Based on the results of the Vlookup function, they locate a value that meets the criteria and also matches the reference value.read more
Logical test means having a logical output which is either true or false, in excel we can perform logical test to any of the situations, the most commonly used logical test is by using the equals to operator which is “=” is we use =A1=B1 in cell A2 then it will return true if the values are equal and false if the
Contents
- 1 How do you write a logical test in excel?
- 2 What is the logical test?
- 3 How do you use logical tests?
- 4 What are the 3 types of data in excel?
- 5 What should be included in a logical test?
- 6 How do you answer a logic test?
- 7 What is an example of logical?
- 8 How do I prepare for a logic test?
- 9 How do I test values in Excel?
- 10 What is Yearfrac formula in Excel?
- 11 What is value if true in Excel?
- 12 How do you explain Vlookup in interview?
- 13 What is formula bar?
- 14 How many types of MS Excel?
- 15 How do you think logically?
- 16 What is logical thinking example?
- 17 Why is logical reasoning important?
- 18 What is logical process?
- 19 What is logical in simple words?
- 20 What are the 4 types of logic?
How do you write a logical test in excel?
To test if a number in A1 is greater than zero and less than 10, use =AND(A1>0,A1… The OR function is a logical function to test multiple conditions at the same time. OR returns either TRUE or FALSE. For example, to test A1 for either “x” or “y”, use =OR(A1=”x”,A1=”y”).
A logical reasoning test measures your ability or aptitude to reason logically. Generally, logical reasoning tests measure non-verbal abilities. You must, through logical and abstract reasoning, extract rules, analogies and structures which you subsequently use to find a correct answer among a set of possible options.
How do you use logical tests?
Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it’s false. For example: =IF(A2>B2,”Over Budget”,”OK”) =IF(A2=B2,B4-A4,””)
What are the 3 types of data in excel?
You enter three types of data in cells: labels, values, and formulas. Labels (text) are descriptive pieces of information, such as names, months, or other identifying statistics, and they usually include alphabetic characters.
What should be included in a logical test?
Some examples of logical tests that you can use with the IF function include:
- C5=C6 (compare cell C5 to C6.
- C5>C6 (if C5 is greater then TRUE, otherwise FALSE)
- C5=”” (if cell C5 is empty then TRUE, otherwise FALSE)
- SUM(A5:A10)>B5 (if the sum of cells A5 to A10 is greater than B5 then TRUE, otherwise FALSE).
How do you answer a logic test?
Our logical reasoning tips and advice
- Start with the easiest pattern. In most logical reasoning questions, there will be multiple logical variables going on in order to determine the correct answer.
- Check the Pattern Works Forwards and Backwards.
- Be Aware of Time.
- Lots of practice.
What is an example of logical?
The definition of logic is a science that studies the principles of correct reasoning. An example of logic is deducing that two truths imply a third truth. An example of logic is the process of coming to the conclusion of who stole a cookie based on who was in the room at the time.
How do I prepare for a logic test?
Here are our top ten tips to prepare for a logical reasoning test:
- Step 1: Know what you’re taking.
- Step 2: Practice realistic sample tests.
- Step 3: Check your answers.
- Step 4: Think laterally.
- Step 5: Create a strategy to tackle the questions.
- Step 6: Get used to timed conditions.
- Step 7: Practice like it’s the real test.
How do I test values in Excel?
To run the t-test, arrange your data in columns as seen below. Click on the “Data” menu, and then choose the “Data Analysis” tab. You will now see a window listing the various statistical tests that Excel can perform. Scroll down to find the t-test option and click “OK”.
What is Yearfrac formula in Excel?
Description. The Microsoft Excel YEARFRAC function returns the number of days between 2 dates as a year fraction. The YEARFRAC function is a built-in function in Excel that is categorized as a Date/Time Function. It can be used as a worksheet function (WS) in Excel.
What is value if true in Excel?
The IF function runs a logical test and returns one value for a TRUE result, and another for a FALSE result. For example, to “pass” scores above 70: =IF(A1>70,”Pass”,”Fail”). More than one condition can be tested by nesting IF functions.
How do you explain Vlookup in interview?
Answer: VLOOKUP is used to find the data in a large spreadsheet by lookup value in another worksheet. To use the lookup function, we should have common values in both data. For example, we want to search for the phone number of a person.
What is formula bar?
Alternatively referred to as a formula box, the formula bar is a section in Microsoft Excel and other spreadsheet applications. It shows the contents of the current cell and allows you to create and view formulas. The two pictures below are examples of what the formula bar looks like in Microsoft Excel.
How many types of MS Excel?
Excel 2010’s Three Data Types and Their Default Formats.
How do you think logically?
The following are steps you can take to use logical thinking in the workplace:
- Take time to practice your ability to think logically.
- Get familiar with the different kinds of logical reasoning.
- Keep your emotions out of it.
- Know what your goal is.
What is logical thinking example?
Logical thinking is the process of applying a chain of reasoning to overcome a problem and reach a conclusion.A good example of logical thinking in action is the game of chess. Playing chess involves working through a sequence of individual steps which take you closer to victory.
Why is logical reasoning important?
Why are logical thinking skills important? Logical thinking skills are important because they can help you reason through important decisions, solve problems, generate creative ideas and set goals—all of which are necessary for developing your career.
What is logical process?
The Logical Process Model defines the business activities that make up the business processes. The activities to be implemented by the architecture, including relationships to entities, roles and actors, are incorporated into the model. This guideline explains how to develop a Logical Process Model.
What is logical in simple words?
Logical describes something that comes from clear reasoning.The adjective logical is rooted in the Greek word logos, which means “reason, idea, or word.” So calling something logical means it’s based on reason and sound ideas — in other words, thought out with mathematical precision and removed from emotion.
What are the 4 types of logic?
The four main types of logic are:
- Informal logic: Uses deductive and inductive reasoning to make arguments.
- Formal logic: Uses syllogisms to make inferences.
- Symbolic logic: Uses symbols to accurately map out valid and invalid arguments.
- Mathematical logic Uses mathematical symbols to prove theoretical arguments.
The IF function runs a logical test and returns one value for a TRUE result, and another value for a FALSE result. The result from IF can be a value, a cell reference, or even another formula. By combining the IF function with other logical functions like AND and OR, you can test more than one condition at a time.
Syntax
The generic syntax for the IF function looks like this:
=IF(logical_test,[value_if_true],[value_if_false])
The first argument, logical_test, is typically an expression that returns either TRUE or FALSE. The second argument, value_if_true, is the value to return when logical_test is TRUE. The last argument, value_if_false, is the value to return when logical_test is FALSE. Both value_if_true and value_if_false are optional, but you must provide one or the other. For example, if cell A1 contains 80, then:
=IF(A1>75,TRUE) // returns TRUE
=IF(A1>75,"OK") // returns "OK"
=IF(A1>85,"OK") // returns FALSE
=IF(A1>75,10,0) // returns 10
=IF(A1>85,10,0) // returns 0
=IF(A1>75,"Yes","No") // returns "Yes"
=IF(A1>85,"Yes","No") // returns "No"
Notice that text values like «OK», «Yes», «No», etc. must be enclosed in double quotes («»). However, numeric values should not be enclosed in quotes.
Logical tests
The IF function supports logical operators (>,<,<>,=) when creating logical tests. Most commonly, the logical_test in IF is a complete logical expression that will evaluate to TRUE or FALSE. The table below shows some common examples:
Goal | Logical test |
---|---|
If A1 is greater than 75 | A1>75 |
If A1 equals 100 | A1=100 |
If A1 is less than or equal to 100 | A1<=100 |
If A1 equals «Red» | A1=»red» |
If A1 is not equal to «Red» | A1<>»red» |
If A1 is less than B1 | A1<B1 |
If A1 is empty | A1=»» |
If A1 is not empty | A1<>»» |
If A1 is less than current date | A1<TODAY() |
Notice text values must be enclosed in double quotes («»), but numbers do not. The IF function does not support wildcards, but you can combine IF with COUNTIF to get basic wildcard functionality. To test for substrings in a cell, you can use the IF function with the SEARCH function.
Pass or Fail example
In the worksheet shown above, we want to assign either «Pass» or «Fail» based on a test score. A passing score is 70 or higher. The formula in D6, copied down, is:
=IF(C5>=70,"Pass","Fail")
Translation: If the value in C5 is greater than or equal to 70, return «Pass». Otherwise, return «Fail».
Note that the logical flow of this formula can be reversed. This formula returns the same result:
=IF(C5<70,"Fail","Pass")
Translation: If the value in C5 is less than 70, return «Fail». Otherwise, return «Pass».
Both formulas above, when copied down, will return correct results.
Note: If you are new to the idea of formula criteria, this article explains many examples.
Assign points based on color
In the worksheet below, we want to assign points based on the color in column B. If the color is «red», the result should be 100. If the color is «blue», the result should be 125. This requires that we use a formula based on two IF functions, one nested inside the other. The formula in C5, copied down, is:
=IF(B5="red",100,IF(B5="blue",125))
Translation: IF the value in B5 is «red», return 100. Else, if the value in B5 is «blue», return 125.
There are three things to notice in this example:
- The formula will return FALSE if the value in B5 is anything except «red» or «blue»
- The text values «red» and «blue» must be enclosed in double quotes («»)
- The IF function is not case-sensitive and will match «red», «Red», «RED», or «rEd».
This is a simple example of a nested IFs formula. See below for a more complex example.
Return another formula
The IF function can return another formula as a result. For example, the formula below will return A1*5% when A1 is less than 100, and A1*7% when A1 is greater than or equal to 100:
=IF(A1<100,A1*5%,A1*7%)
Nested IF statements
The IF function can be «nested». A «nested IF» refers to a formula where at least one IF function is nested inside another in order to test for more conditions and return more possible results. Each IF statement needs to be carefully «nested» inside another so that the logic is correct. For example, the following formula can be used to assign a grade rather than a pass / fail result:
=IF(C6<70,"F",IF(C6<75,"D",IF(C6<85,"C",IF(C6<95,"B","A"))))
Up to 64 IF functions can be nested. However, in general, you should consider other functions, like VLOOKUP or XLOOKUP for more complex scenarios, because they can handle more conditions in a more streamlined fashion. For a more details see this article on nested IFs.
Note: the newer IFS function is designed to handle multiple conditions without nesting. However, a lookup function like VLOOKUP or XLOOKUP is usually a better approach unless the logic for each condition is custom.
IF with AND, OR, NOT
The IF function can be combined with the AND function and the OR function. For example, to return «OK» when A1 is between 7 and 10, you can use a formula like this:
=IF(AND(A1>7,A1<10),"OK","")
Translation: if A1 is greater than 7 and less than 10, return «OK». Otherwise, return nothing («»).
To return B1+10 when A1 is «red» or «blue» you can use the OR function like this:
=IF(OR(A1="red",A1="blue"),B1+10,B1)
Translation: if A1 is red or blue, return B1+10, otherwise return B1.
=IF(NOT(A1="red"),B1+10,B1)
Translation: if A1 is NOT red, return B1+10, otherwise return B1.
IF cell contains specific text
Because the IF function does not support wildcards, it is not obvious how to configure IF to check for a specific substring in a cell. A common approach is to combine the ISNUMBER function and the SEARCH function to create a logical test like this:
=ISNUMBER(SEARCH(substring,A1)) // returns TRUE or FALSE
For example, to check for the substring «xyz» in cell A1, you can use a formula like this:
=IF(ISNUMBER(SEARCH("xyz",A1)),"Yes","No")
Read a detailed explanation here.
More information
- Read more about nested IFs
- Learn how to use VLOOKUP instead of nested IFs (video)
- 50 Examples of formula criteria
Notes
- The IF function is not case-sensitive.
- To count values conditionally, use the COUNTIF or the COUNTIFS functions.
- To sum values conditionally, use the SUMIF or the SUMIFS functions.
- If any of the arguments to IF are supplied as arrays, the IF function will evaluate every element of the array.
Excel Logical Test (Table of Contents)
- Introduction to Logical Test in Excel
- How to Use Logical Functions in Excel?
Introduction to Logical Test in Excel
A logical test means the system will check for a given condition, and if that logic is satisfied, then it will display the results according to logic in excel. Logic is anything that we check; suppose if a student secures more than 35 marks, we can consider it as pass otherwise fail. An employee should get a bonus if his salary from 25k to 30k. like this, we can check for any logic in the real world and execute the results accordingly. To perform these results, Excel has multiple logical functions. With the help of those functions, we can perform our logical tests in excel.
Available excel logical functions are IF, AND, OR, NOT, XOR, etc.
How to Use Logical Functions in Excel?
The logical Test in excel is very simple and easy to use. Let’s understand how to use logical functions in excel.
You can download this Logical Test Excel Template here – Logical Test Excel Template
#1 – IF Function
If function checks for the given condition and provides results as per condition satisfaction. Consider a small condition; if age is greater than 50, the result should be Eligible for pension; otherwise, should not be eligible for a pension.
First, understand the IF syntax. Below is the screenshot of IF syntax.
If you observe, first is a logical test which is the condition that should satisfy in excel. The second is Value_If_True means what to print if the condition is true. Last is Value_if_false what to print if the condition is false.
Now input the data and apply the formula in cell B2 as below.
The output will be as given below.
Drag the Formula to the rest of the cells.
We can observe that wherever the age is greater than 60, the results are “Eligible for Pension” if it is less than 60 “Not eligible for pension”.
In addition to IF, there is Nested IF, and we can also write multiple logics as per requirements.
#2 – AND Function
AND logical test is used in excel when we want to check whether two conditions are satisfied or not. We will see the syntax of AND when we give =AND in any cell; we can find the syntax like below.
In the picture, we can observe the syntax as logic 1, logic 2 and so on. How many logics there will be, all should be satisfied; then only the results will be “True”.
Now we will apply the formula to the small logic shown in the picture. We want to know the candidate’s A, B, C who cleared two tests with more than 50 marks. If both tests secured more than 50, then it will display “True” otherwise “False”.
The Formula is applied to cell D2.
The output will be as given below.
Drag the Formula to the rest of the cells.
Observe the above picture B2 is greater than 50 and C2 is greater than 50; hence it is “True”. If we observe candidate B who secured less than 50 in Test 1 and greater than 50 in Test 2, however, as per AND logic, both logics should satisfy then only the result will be “True”. Since candidate A satisfied both logics, hence it is “True”. We can use “AND” logic for better logics application with the combination of “IF”.
#3 – OR Function
OR logical test in excel will give results if anyone logic or condition satisfies. If both the conditions are false, then the results will be false.
Below picture for OR syntax.
If we observe the syntax, it is logic1, logic2, and so on like AND logic, but all the logic should satisfy any logic here. We will consider the same logic of AND, and both the tests should secure more than 50 then only True. In OR logic, if any One test secures greater than 50, then it will be True.
The output will be as given below.
Drag the Formula to the rest of the cells.
Observe the red color box formula and observe the results in column D. All are “True” because all candidates secured greater than 50 in at least in one test.
Change the values of two tests less than 50 and observe for any one candidate.
Now, as the results of both tests are less than 50, hence it is “False”. OR can also be used with the combination of IF for better logic applications.
#4 – XOR Function
XOR logical excel function works in such a way if any One logic satisfies, it will give the result as True if both the logics are satisfied or if both are not satisfied, then it will be False. If we want the results as True, only a single condition should satisfy.
The syntax of XOR is similar to, OR we just need to add X at the beginning.
We will use the same example to apply XOR too.
The output will be as given below.
Drag the Formula to the rest of the cells.
Observe the formula and observe the results. When candidate A satisfies both Test1 and Test2 with more than 50, Falsesimilarly Candidate C does not satisfy both tests, hence False. Candidate B not secured more than 50 in test1 but secured more than 50 in test2, so the condition satisfied hence True.
#5 – NOT Function
The NOT logical test in excel returns False when the condition is satisfied, True when the condition is not satisfied. Let see the syntax of NOT then we will see how we can use it.
We can observe it only has logic that needs to check. Now we will apply to a situation where we can use it. Suppose we want to display false for voting if age is less than 18.
The output will be as given below.
Drag the Formula to the rest of the cells.
Observe the above picture if Age is less than or equal to 18, which means it is giving False if age is greater than 18, it returns True. We can use the NOT function to perform other logical operations with the combination of other excel logical functions like IF, OR, etc.
Things to Remember about Logical Test in Excel
- Logical tests are used to return the values which depend on the satisfaction of the condition in excel. Different logical tests follow different logics in excel.
- If the function returns one value if the condition is satisfied and returns another value if a condition is not satisfied, it returns values that the user provides.
- OR function logic is it will return value as True if any One condition satisfied out of two conditions.
- AND function logic is it will return value as True if both the conditions are satisfied. If any of the condition is not satisfied, it will return a False value.
- XOR excel logical test will return a True value if only one condition satisfies out of two. It will return False if both are satisfied or not satisfied.
- NOT function returns True if a condition is not satisfied and returns False if a condition is satisfied.
- Depend on the situation and requirement; we can use a combination of all these Logical tests in excel.
Recommended Articles
This has been a guide to Logical Tests in Excel. Here we discuss how to use logical functions like IF, AND, OR, XOR, and NOT in Excel, along with practical examples and a downloadable template. You may learn more about excel from the following articles –
- AND Function in Excel
- OR in Excel
- NOT in Excel
- SUMIF Function in Excel
What is a logical test
Logical tests are everywhere.
- Is my salary higher than my colleague’s?
- Is my rent higher than my neighbor’s?
- Is the quantity in stock larger now than at the beginning of the month?
- Does a ticket closed or not?
- …
A logical test is just a comparison between 2 items 😉
Construction of a logical test
You can create a logical test in a cell WITHOUT using the IF function.
In fact, it is the opposite. A test is used in an IF function.
A test in Excel is very simple.
- Start your test with the equals sign =.
- Then add a value or cell reference
- Then the logical symbol (see below)
- Then another cell or another value
For instance, write the following formula in a cell to see the result
=C2=»Closed»
Logical symbols you can use
To create a test, you can use one of the following symbols
- = equal to
- > greater than
- >= greater than or equal to
- < lower than
- <= lower or equal to
- <> not equal to
Exercise online
Click on the following image to open the exercise
Examples of logical tests
In the previous example, we created a test with the string «Closed». But you can build a test with numerical values or formulas
Example 1: Does the age is greater than 21?
If you want to know if the cell contents are greater than a specific value, like 21, you can write the following test.
=B2>21
Example 2: Compare 2 cells
You can also create the same test but this time, the value 21 is in the cell G4. So, instead of comparing one cell with one value, you can also create a test between 2 cells
=B2>=$G$4
In this example, we must add dollars to block the reference of the cell G4
Example 3: Is the cell empty or not?
Now, if you want to know if a cell is not empty, you will write the following formula
=A2<>»»
The 2 double quotes is the code for an empty cell (it’s a string with nothing in between) 😉
Many functions return TRUE or FALSE
Excel has a collection of functions that return TRUE or FALSE. These functions start with IS
- ISBLANK
- ISERROR
- ISFORMULA
- ISNA
- ISNUMBER
- ISNONTEXT
For instance, a common mistake in Excel is to write the month in letter instead of customising your date format. So, because a date is a number in Excel, we can create this test to check if a cell contains a date or not.
=ISNUMBER(B2)
Convert the result to 1 or 0
There is a trick to convert the value TRUE or FALSE to 1 or 0. The detail in this article.
Use conditional formatting
Conditional formatting is a goldmine for customizing and improving your Excel documents.
Conditional formatting allows us to change the color of cells according to their values automatically. And, of course, logical tests help you to create your rules to change the format according to the result of the test.