# Writing a nested if statement in excel

Nested IF Functions The IF function allows the user to ask Excel to test certain criteria and to perform different actions depending on if the criteria is met or not. But often our data analysis requires that we test multiple criteria. This might lead to one of the parameters of the IF function containing an IF function! Based on the following criteria: The simplest way to complete this process is to put all of your categories and criteria in a table.

Load your Data Set Load your data into a vertical column and add a field next to it to assign it to the proper category. Decide on your approach For any Nested IF Statement, there will be multiple ways to write the actual formula.

If the logical test for the second category fails, the third category is selected without using another if statement. The last logical test of a Nested IF does not necessarily need an IF Statement, however, you would have had to write one if your third category had a defined boundary.

To begin, we start out by writing our first IF statement for the first cell we want to evaluate: Therefore, we basically want to see if the number 33 is less than Note that after selecting our first true condition, we do NOT close off the formula with a parenthesis.

Therefore, just input Category 3. Close out both the logical test 1 and logical test 2 by placing two parenthesis at the end of the formula Step 9: To make that process easier, you have to remember to reference lock the appropriate cells before copying your formula down.

## Excel Formula Training

To determine the cells you need to reference lock, just think about which cells you need to float change every time you move to a different valueand which cells you need to stay the same for every formula. In the example below, the value we need to float is C3, or the data set value, because we want each one of these values to be assessed in their individual formula.

Therefore, for all instances of C3, we do NOT reference lock. If any of these values were to change as we copied the Nested IF down, the formula would not work properly. Therefore, go ahead and reference lock all cells related to the category table to the right, while leaving your data cell value unlocked. Copy your formula down to apply it to all data sets This can be done by double clicking the lower right hand corner of the cell. Each value in our data set now has been assigned to a category of low, medium, or high and your Nested IF Statement is complete.

See the image below for an example of a more complex Nested IF Statement: The key problems with wring a Nested IF Statement are: While they are still somewhat prone to error, they are much more scalable and easier to audit for mistakes. The two alternatives are: Despite my problems with the formulawriting the Nested IF teaches you how logical structuring basically, writing IF Statements works in Excel.

Having a strong level of comfort around logical structuring is critically important to Excel proficiency.Excel Formula Training. Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, .