Skip to main content

Excel lesson 5th

Things will not always be the way we want them to be. The unexpected can happen. For example, let's say you have to divide numbers. Trying to divide any number by zero (0) gives an error. Logical functions come in handy such cases. In this tutorial, we are going to cover the following topics.
In this tutorial, we are going to cover the following topics.

What is a Logical Function?

It is a feature that allows us to introduce decision-making when executing formulas and functions. Functions are used to;
  • Check if a condition is true or false
  • Combine multiple conditions together
What is a condition and why does it matter?
A condition is an expression that either evaluates to true or false. The expression could be a function that determines if the value entered in a cell is of numeric or text data type, if a value is greater than, equal to or less than a specified value, etc.

IF Function example

We will work with the home supplies budget from this tutorial. We will use the IF function to determine if an item is expensive or not. We will assume that items with a value greater than 6,000 are expensive. Those that are less than 6,000 are less expensive. The following image shows us the dataset that we will work with.
Logical functions (operators) and conditions in Excel
  • Put the cursor focus in cell F4
  • Enter the following formula that uses the IF function
=IF(E4<6000,"Yes","No")
HERE,
  • "=IF(…)" calls the IF functions
  • "E4<6000" is the condition that the IF function evaluates. It checks the value of cell address E4 (subtotal) is less than 6,000
  • "Yes" this is the value that the function will display if the value of E4 is less than 6,000
  • "No" this is the value that the function will display if the value of E4 is greater than 6,000
When you are done press the enter key
You will get the following results
Logical functions (operators) and conditions in Excel

Excel Logic functions explained

The following table shows all of the logical functions in Excel
S/NFUNCTIONCATEGORYDESCRIPTIONUSAGE
01ANDLogicalChecks multiple conditions and returns true if they all the conditions evaluate to true.=AND(1 > 0,ISNUMBER(1))
02FALSELogicalReturns the logical value FALSE. It is used to compare the results of a condition or function that either returns true or falseFALSE
03IFLogicalVerifies whether a condition is met or not. If the condition is met, it returns true. If the condition is not met, it returns.=IF(ISNUMBER("22"),"Yes", "No")
04IFERRORLogicalReturns the expression value if no error occurs. If an error occurs, it returns the error value=IFERROR(5/0,"Divide by zero error")
05IFNALogicalReturns value if #N/A error does not occur. If #N/A error occurs, it returns NA value. #N/A error means a value if not available to a formula or function.=IFNA(D6*E6,0) N.B the above formula returns zero if both or either D6 or E6 is/are empty
06NOTLogicalReturns true if the condition is false and returns false if condition is true=NOT(ISTEXT(0)) N.B. the above function returns true. This is because ISTEXT(0) returns false and NOT function converts false to TRUE
07ORLogicalUsed when evaluating multiple conditions. Returns true if any or all of the conditions are true. Returns false if all of the conditions are false=OR(D8="admin",E8="cashier") N.B. the above function returns true if either or both D8 and E8 admin or cashier
08TRUELogicalReturns the logical value TRUE. It is used to compare the results of a condition or function that either returns true or falseTRUE

Nested IF functions

A nested IF function is an IF function within another IF function. Nested if statements come in handy when we have to work with more than two conditions. Let's say we want to develop a simple program that checks the day of the week. If the day is Saturday we want to display "party well", if it's Sunday we want to display "time to rest", and if it's any day from Monday to Friday we want to display, remember to complete your to do list.
A nested if function can help us to implement the above example. The following flowchart shows how the nested IF function will be implemented.
Logical functions (operators) and conditions in Excel
The formula for the above flowchart is as follows
=IF(B1="Sunday","time to rest",IF(B1="Saturday","party well","to do list"))
HERE,
  • "=IF(….)" is the main if function
  • "=IF(…,IF(….))" the second IF function is the nested one. It provides further evaluation if the main IF function returned false.

Practical example

Logical functions (operators) and conditions in Excel
Create a new workbook and enter the data as shown below
Logical functions (operators) and conditions in Excel
  • Enter the following formula
=IF(B1="Sunday","time to rest",IF(B1="Saturday","party well","to do list"))
  • Enter Saturday in cell address B1
  • You will get the following results
Logical functions (operators) and conditions in Excel

Summary

Logical functions are used to introduce decision-making when evaluating formulas and functions in Excel.

Comments

Popular posts from this blog

Excel lesson 4th

Excel Formulas & Functions: Date, Time, String, VLOOKUP Formulas and functions are the building blocks of working with numeric data in Excel. This article introduces you to formulas and functions. In this article, we will cover the following topics. What is a formula? Mistakes to avoid when working with formulas in Excel What is a function? (Function Wizard) The importance of functions Common functions Numeric functions String functions Date Time functions V Lookup function Tutorials Data For this tutorial, we will work with the following datasets. Home supplies budget S/N ITEM QTY PRICE SUBTOTAL Is it Affordable? 1 Mangoes 9 600     2 Oranges 3 1200     3 Tomatoes 1 2500     4 Cooking Oil 5 6500     5 Tonic Water 13 3900     House Building Project Schedule S/N ITEM START DATE END DATE DURATION (DAYS) 1 Survey land 04/02/2015 07/02/2015   2 Lay Foundation 1...

Excel lesson 7

How to Create Budget In Excel Spreadsheet with Template "Money is a tool. Used properly it makes something beautiful- used wrong, it makes a mess!" - Bradley Vinson It takes discipline to use money properly. In this tutorial, we are going to look at how we can use Excel to properly manage our personal finances. We will cover the following topics. Why manage Budget? Major components of a personal finance system Using Excel to set personal budgets, record income and expenses Visualizing the data using charts Why manage Budget? Let's face it, the world we live in is fuelled by money. We go to school to get a good job, engage in business and other related activities with the main goal of making money. If we do not manage our personal finances properly, then all of our efforts go to waste. Most people spend more than they earn. In order to be financially successful, one needs to develop a habit of spending less than they earn and invest the surplus in ...

Excel lesson 3rd

Excel Data Validation, Filters, Grouping In this tutorial, we are going to cover the following topics. Data validation Data filters Group and Ungroup Ading images to spreadsheets Data validation Data validation is very important in the sense that it helps us avoid mistakes that can be avoided . Let's assume you are recording student exam marks and you know the minimum is 0 and the maximum is 100. You can take advantage of validation features to ensure that only values between 0 and 100 are entered. Add a new sheet in your workbook by clicking on the plus button at the bottom of the worksheet. Add a column for S/N, Name and Score. Your sheet should look as follows S/N Name Score 1 Jane 2 James 3 Jones 4 Jonathan 5 John Click on the DATA tab Select the cells C2 to C6 (The cells that will be used to record the scores) Click on Data validation drop down list. Click on Data validation. You will get the following dialogue window Click...