8.2 NESTING AND, OR, NOT FUNCTIONS INSIDE AN IF FUNCTION – Excel For Decision Making (2024)

Let us suppose you are in the process of deciding which university to attend for your Master Degree Program. You have a list of criteria that must be met, or you will not choose that school. You may have a list similar to the one below:

The university you want to attend:

  1. Must have a Graduate program.
  2. Must have a Business program.
  3. Must not put you into a debt greater than $20,000.
  4. Must lead to earnings of at least $60,000 per year after 10 years.

In our data dictionary, we can locate fields in our data set that will provide us with useful information.

  1. Graduate program related field and condition: [@HIGHDEG]=4
  2. Business program related field and condition: [@PCIP52]>0
  3. Debt related field and condition: [@[GRAD_DEBT_MDN_SUPP]]<20000
  4. Earnings-related field and condition: [@[MD_EARN_WNE_P10]]>60000

If you think about it, these conditions boil down to a few simple logical tests, like ones covered in Chapter 3 when we used the IF function to see if someone has passed or failed a test. Here, we have 4 logical tests that ALL must be TRUE before you can pick from a list of institutions that all meet your criteria. In our College Scorecard dataset and its related Data Dictionary, we have fields that we can use to filter an Excel table or a Pivot Table to narrow down our choices. However, in this chapter, we will look at using logical functions to find an answer.

IF you were fond of using logical functions, THEN you may find the use of the following functions in combination with our IF function. On their own, the AND, OR, NOT are logical functions that will help you evaluate up to 255 conditions and return a TRUE or FALSE value. The AND logical function determines if ALL conditions in a test are TRUE. The OR logical function determines if ANY conditions in a test are TRUE. The NOT logical function makes sure one value is not equal to another.

The syntax for these three functions are as follows:

=AND(logical1,[logical2], …)

=OR(logical1,[logical2], …)

=NOT(logical1,[logical2], …)

Let us use the AND function to test which institutions meet our the first two conditions from above, namely, that they have a graduate program (HIGHDEG=4) and they have more than 0 under the average % of enrolled students in their business program (PCIP52>0). We will use more criteria as we move along in this chapter.

  1. Open the College Scorecard Data Excel file you used for Chapter 6. (You can download a fresh copy from here.)
  2. Convert your data set into an Excel table so that your formula will use your field names (column headings) and will be easier to check for accuracy or to interpret.
  3. Considering you have over 120 columns in this data set, you can select, right-click, and hide columns you do not use for the moment.Insert a column next to the PCIP52 column that shows the percentage of business students. Rename the column TEST.
  4. Start your expression by typing in =AND(, click into the first cell in the HIGHDEG column and set your criteria, then click into the PCIP52 column, and set your criteria for that field. You will see descriptive names due to the Excel Table structure instead of cell references. Press enter, and the column will autofill with your output as seen in Figure 8.2.1.
    8.2 NESTING AND, OR, NOT FUNCTIONS INSIDE AN IF FUNCTION – Excel For Decision Making (1)
  5. Alternatively, you can use the function library route of populating your formula with your arguments as seen in Figure 8.2.2 below.
    8.2 NESTING AND, OR, NOT FUNCTIONS INSIDE AN IF FUNCTION – Excel For Decision Making (2)
  6. You can now filter the data to show those institutions that meet your criteria. Complete the following practice exercises to add more logical tests to your formula.

Exercise

Insert an AND function that tests to see if ALL four of your criteria are met:

  1. Graduate program related field and condition: [@HIGHDEG]=4
  2. Business program related field and condition: [@PCIP52]>0
  3. Debt related field and condition: [@[GRAD_DEBT_MDN_SUPP]]<20000
  4. Earnings-related field and condition: [@[MD_EARN_WNE_P10]]>60000

Build an OR function that tests to see if ALL four of your criteria are met:

  1. Graduate program related field and condition: [@HIGHDEG]=4
  2. Business program related field and condition: [@PCIP52]>0
  3. Debt related field and condition: [@[GRAD_DEBT_MDN_SUPP]]<20000
  4. Earnings-related field and condition: [@[MD_EARN_WNE_P10]]>60000

How many institutions are there that meet ALL your criteria?

What are your criteria for looking at an undergraduate or graduate program?

What other questions would you ask of your data knowing the fields in the data dictionary?

What other methods can you use to get answers to such questions? Do you a preference for one over another?

Using AND, OR, NOT in conjunction with the IF function will let you return custom outputs or run calculations. You can automate the evaluation of logical tests by NESTING the AND, OR, NOT functions inside a single IF function. This means that if we have multiple conditions but we want to return a single output, we can nest any of the conjunction functions inside an IF and specify outputs accordingly.

The syntax for these three functions are as follows:

=IF(AND(Something is True, Something else is True), Value if True, Value if False)

=IF(OR(Something is True, Something else is True), Value if True, Value if False)

=IF(NOT(Something is True), Value if True, Value if False)
(AND, OR, NOT source: support.office.com.)

Let us use the IF function and nest and AND function inside it to test which institutions meet ALL our four previous criteria (HIGHDEG=4, PCIP52>0, GRAD_DEBT_MDN_SUPP<20000, MD_EARN_WNE_P10>60000). We nest the AND inside the IF function so that we can have an output other than TRUE or FALSE. In this instance, we want an output that says “This could be it!” if ALL our conditions are met, we want an output that say “No.” if any of my conditions are not met.

  1. Let us go back to our College Scorecard Data Excel file with an Excel table already inserted in it. Leaving columns from earlier practices will not impact how your formulas work, so there is no need to delete anything.
  2. Start your expression by typing in =IF(, then immediately after that, add the AND( and add all your criteria. You will see descriptive names to make adding the criteria you want in your graduate school.
    “=IF(AND([@PCIP52]>0.15,[@HIGHDEG]=4,[@[GRAD_DEBT_MDN_SUPP]]<20000,[@[MD_EARN_WNE_P10]]>60000),”This is it!”,”No”)”
  3. Press enter, and the column will autofill.
  4. You can now filter the data to show those institutions that meet your criteria. Complete the following practice exercises to add more logical tests to your formula.

Exercises

Build a nested function that tests to see if ALL of the following criteria are met and outputs to “Yes!” if all TRUE, and output to a “No.” if any of the characters are not true:

  1. Graduate program.
  2. The program of your choice.
  3. The region of your choice.
  4. The site of the institution the size of your choice.
  5. Earnings of your choice.
  6. Debt amount of your choice.

How many institutions are there that meet ALL your criteria?

How do the answers change if you replace the AND with an OR function?

What other questions would you ask of your data knowing the fields in the data dictionary?

What other methods can you use to get answers to such questions? Do you a preference for one over another?

Attributions:

Chapter 8 by Emese Felvégi and Robert McCarn. CC BY-NC-SA 3.0.

Media Attributions

  • AND
  • ANDv2
8.2 NESTING AND, OR, NOT FUNCTIONS INSIDE AN IF FUNCTION – Excel For Decision Making (2024)

FAQs

8.2 NESTING AND, OR, NOT FUNCTIONS INSIDE AN IF FUNCTION – Excel For Decision Making? ›

nesting and, or, not inside an if function. Using AND, OR, NOT in conjunction with the IF function will let you return custom outputs or run calculations. You can automate the evaluation of logical tests by NESTING the AND, OR, NOT functions inside a single IF function.

How do you use if and nested IF function in Excel? ›

If you clicked IF, the Function arguments dialog box displays the arguments for the IF function. To nest another function, you can enter it into the argument box. For example, you could enter SUM(G2:G5) in the Value_if_true box of the IF function. Enter any additional arguments that are needed to complete your formula.

Can you put a function inside an if statement Excel? ›

Nested IF functions, meaning one IF function inside of another, allow you to test multiple criteria and increases the number of possible outcomes.

Which function is used for decision making in Excel? ›

Use an IF Function to make logical comparisons between a value and what you expect. Create a VLOOKUP calculation to look up information in a table.

Can you nest the and or or functions within an if function? ›

You can automate the evaluation of logical tests by NESTING the AND, OR, NOT functions inside a single IF function. This means that if we have multiple conditions but we want to return a single output, we can nest any of the conjunction functions inside an IF and specify outputs accordingly.

What is an example of a nested if statement? ›

A nested if statement is an if-else statement with another if statement as the if body or the else body. Here's an example: if ( num > 0 ) // Outer if if ( num < 10 ) // Inner if System. out.

Can a function be inside an if statement? ›

But to answer your question you can definitely put an if statement in a function. A function is just a block of code that sets a side a chunk of code for easy access when called. So you can pretty much put anything in a function.

Can you put a formula in an if function? ›

Simple IF examples

In this example, the formula in cell D2 says: IF(C2 = 1, then return Yes, otherwise return No)As you see, the IF function can be used to evaluate both text and values. It can also be used to evaluate errors.

Can I use ifs and and function in Excel? ›

In Excel IF formulas, you are not limited to using only one logical function. To check various combinations of multiple conditions, you are free to combine the IF, AND, OR and other functions to run the required logical tests.

How to make a decision formula in Excel? ›

How to create a decision tree in Excel in 5 steps
  1. Choose a program to use with Excel. ...
  2. Enter the data into an Excel spreadsheet. ...
  3. Create dialog or text boxes that display information. ...
  4. Insert a starting condition for the decision tree to activate. ...
  5. Design equations for each of the decisions the tree details.

Which is the decision-making function? ›

A decision-making process is a series of steps one or more individuals take to determine the best option or course of action to address a specific problem or situation. Often, managers and executives use the process to plan how to carry out business initiatives or set specific actions in motion.

How do you use an IF and match function in Excel? ›

To compare two ranges cell-by-cell and return the logical value TRUE if all the cells in the corresponding positions match, supply the equally sized ranges to the logical test of the AND function: AND(range A = range B) That's how to use the If match formula in Excel.

How do you use if and else function in Excel? ›

Use =IF(logical_test, [value_if_true], [value_if_false]) to create an if-else statement. Add AND, OR, or NOT functions to evaluate more complex situations. Create nested IF statements to evaluate multiple conditions at different levels.

How do you use if and between in Excel? ›

Between function for text

Enter the formula "=IF(AND(value>=text 1,value<=text 2),"Yes","No")." In the sample table, this formula for cell D2 would be "=IF(AND(C2>=A2,C2<=B2),"Yes","No")."

How do you use two conditions in an IF function in Excel? ›

How do you put 2 conditions in an Excel IF function? To put two conditions in an IF formula in Excel, you can use the AND or OR function along with the IF function. For example, =IF(AND(A1>50, B1>60), “Pass”, “Fail”) will check if the value in cell A1 is greater than 50 and the value in cell B1 is greater than 60.

How to combine two ifs in Excel? ›

Combine multiple IF statements by using the CONCATENATE function or the concatenate operator (&). A formula example can be found here. For experienced Excel users, the best alternative to using multiple nested IF functions might be creating a custom worksheet function using VBA.

What is nested if and multi way if statements? ›

An if statement can be inside another if statement to form a nested if statement. The statement in an if or if-else statement can be any legal Java statement, including another if or if-else statement. The inner if statement is said to be nested inside the outer if statement.

Can I have two if statements in one cell? ›

As a worksheet function, the IF function can be entered as part of a formula in a cell of a worksheet. It is possible to nest multiple IF functions within one Excel formula. You can nest up to 7 IF functions to create a complex IF THEN ELSE statement.

References

Top Articles
Wendy's Copycat Paleo healthy frosty Recipe - My Natural Family
Stuffed Cornish Game Hens - Recipe | Zestful Kitchen
Treasure Hunt Deals Racine Wi
Tyrones Unblocked Games Basketball Stars
Uconn Health Outlook
Wausau Pilot Obituaries
Rent A Center Entertainment Center
20 of the Funniest Obituaries That Will Have You Dying Laughing
Ta Travel Center Las Cruces Photos
Yovanis Pizzeria - View Menu & Order Online - 741 NY-211 East, Middletown, NY 10941 - Slice
2320 Pioneer Rd
Think Up Elar Level 5 Answer Key Pdf
Traveltalkonline
What Does Fox Stand For In Fox News
Crazy 8S Cool Math
Offsale Roblox Items are Going Limited… What’s Next? | Rolimon's
Us151 San Jose
1v1 lol unblocked Game- Play Unblocked Game Online for Free!
Enloe Bell Schedule
2021 Lexus IS 350 F SPORT for sale - Richardson, TX - craigslist
Craigslist Of Valdosta Georgia
Friend Offers To Pay For Friend’s B-Day Dinner, Refuses When They See Where He Chose
Myzynrewards
Dumb Money, la recensione: Paul Dano e quel film biografico sul caso GameStop
The Professor Tape 1 Prof Snow Myvidster
Winta Zesu Net Worth
Live2.Dentrixascend.com
Junior&#039;s Barber Shop &amp; Co &#8212; Jupiter
Uhaul L
Deerc De22 Drone Manual Pdf
Grizzly Expiration Date 2023
How to Start a Travel Agency: Steps and Tips | myPOS
Edict Of Force Poe
Skyward Crawford Ausable
Is Jamie Kagol Married
Sky Nails Albany Oregon
Babbychula
24 Hour Pharmacy Berkeley
Jerry Trainor Shirtless
Gary Keesee Kingdom Principles Pdf
Cb2 South Coast Plaza
Culver's Flavor Of The Day Little Chute
Limestone Bank Hillview
Craigslist Ft Meyers
Wgu Admissions Login
Under One Shining Stone Another Lies
Unblocked Games Shooters
Math Nation Algebra 2 Practice Book Answer Key
"Wordle" #1,176 answer, clues and hints for Saturday, September 7 game
Craigslist Groton
Omgekeerd zoeken op telefoonnummer | Telefoonboek.nl
The Ultimate Guide to Newquay Surf - Surf Atlas
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5620

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.