February 18, 2026

Food with Mood

Food with Mood

The Newbie’s Information to Nested Capabilities in Excel


Nesting in Microsoft Excel includes utilizing one operate as an argument for an additional, permitting you to carry out a number of calculations on the similar time. It saves you from having to make use of helper columns or write varied formulation in varied cells, retaining your worksheet tidier and extra environment friendly.

To observe alongside as you learn this information, download a free copy of the Excel workbook used within the examples. After you click on the hyperlink, you may discover the obtain button within the top-right nook of your display screen, and while you open the file, you may entry every instance on a separate worksheet tab.

Key Definitions

This information makes use of the next three phrases all through, so take a second to know what they imply:

  • Components: A mixture of features, cell references, values, operators, and names that, when used collectively following the equals (=) signal, create a brand new worth.
  • Perform: A pre-defined method that performs a calculation utilizing arguments in a selected order.
  • Argument: An enter that gives info to a operate.

Nesting Capabilities Inside IF in Excel

In case you’re new to nested features in Excel, you need to begin by utilizing the IF function:

=IF(a,b,c)

the place argument a is a logical take a look at, argument b is the worth to return if the take a look at is met, and argument c is the worth to return if the take a look at is not met. For the logical take a look at in argument a, you may nest one other operate.

All examples on this information use common ranges and direct cell references in order that the formulation are simpler to know and the nesting simpler to see.

On this instance, bonuses are paid if the crew’s complete revenue (the sum of the values in cells B2 to B6) exceeds the edge (the worth in cell E1). If the edge is met, you need cell E2 to learn Sure, and if it isn’t, you need it to learn No. The method to realize that is as follows:

=IF(SUM(B2:B6)>=E1,"Sure","No")

So, how does this work?

When creating or studying formulation containing nested features, the bottom line is to start out within the middle, and work outward. Central to this method is the sum of the values in cells B2 to B6, so that is the place you want to begin:

=SUM(B2:B6)
The SUM function used in Excel to calculate the sum of the profits made by five employees.

Subsequent, you need Excel to judge whether or not this sum is the same as or larger than the worth in cell E1. By default, Excel returns TRUE if the analysis is constructive, or FALSE if it is unfavourable—also referred to as Boolean values:

=SUM(B2:B6)>=E1
The SUM function used alongside Boolean logic in Excel to determine whether the sum of the employees' profits exceeds the threshold.

Now, relatively than return Boolean values, you need Excel to return Sure or No. Thus, you want to wrap the SUM method contained in the IF operate, in order that the sum calculation is the logical take a look at (argument a):

=IF(SUM(B2:B6)>=E1,"Sure","No")
The SUM function nested inside IF in Excel to determine whether bonuses are due according to the threshold.

The important thing to working with nested features is knowing the order by which issues are calculated. As you may see within the instance above, nested features are handled first, and the outcomes of those feed the outer elements of the method. So, for those who’re creating a posh method with a lot of nested features, work from the within outward.

You do not have to make use of the SUM operate inside IF. In truth, you may nest just about any operate because the logical take a look at. Right here, the AVERAGE function calculates the typical of the values in cells B2 to F2, and if the result’s greater than 5,000, the method returns Sure (or No if it is not):

=IF(AVERAGE(B2:F2)>5000,"Sure","No")
The AVERAGE function nested inside IF in Excel to determine whether the average of employees' profits exceed the threshold and, thus, trigger a bonus payment.

You’ll be able to then double-click the fill deal with within the bottom-right nook of cell G2 to increase the method to the remaining cells in column G.

The fill handle in the bottom-right corner of cell G2 in Excel is double-clicked to expand a formula to the remaining cells in the column.

This time, the OR operate opens up two choices for the logical take a look at of the IF operate. In different phrases, if the worth in B2 is Ordered or In transit, the method returns In progress. In any other case, it returns Accomplished:

=IF(OR(B2="Ordered",B2="In transit"),"In progress","Accomplished")
The words 'In progress' are returned in cell C2 in Excel due to a formula that nests OR inside IF to evaluate the value in cell B2.

As soon as once more, double-clicking the fill deal with applies the method to the remaining rows within the dataset.

An Excel file with statuses in column C, generated by nesting the OR function inside IF to evaluate the values in column B.

Different Examples of Nesting in Excel

When you begin experimenting with different features, the ability of nesting shortly turns into clear.

Nesting FILTER Inside UNIQUE

On this case, your intention is to extract the names of everybody who has received a prize in New York.

An Excel worksheet, with years in column A, venues in column B, and winners in column C, with a space on the right where New York winners will be extracted.

In different phrases, you need to use the FILTER function to breed a filtered model of column C. To do that, kind:

=FILTER(C2:C15,B2:B15=F1)

into cell E2 and press Enter. C2:C15 is the array you need to filter (individuals’s names), and B2:B15=F1 tells Excel to solely embrace the values the place the corresponding worth in column B equals the worth in cell F1 (New York).

The FILTER function used in Excel to extract from the source data all individuals who have won a prize in New York.

Nonetheless, as you may see within the screenshot above, one of many names is repeated as a result of that individual has received twice in New York. So, you want to nest the FILTER operate inside UNIQUE to return every title solely as soon as:

=UNIQUE(FILTER(C2:C15,B2:B15=F1))
FILTER nested inside UNIQUE in Excel to return a list of non-duplicated names of individuals who have won a prize in New York.

The important thing on this course of is to pressure Excel to carry out the principle calculation first, then use the results of this method to drive one other.

Nested features do not require equal (=) indicators. The equal signal is barely required at first to inform Excel you are coming into a method right into a cell.

Nesting XMATCH Inside INDEX

Considered one of Excel’s hottest operate pairings is INDEX and XMATCH, which work collectively to retrieve and extract a worth from a dataset.

Right here, after coming into a participant’s ID into cell F2, you need to return their rating in cell G2.

An Excel worksheet, with players in column A, their scores in two rounds in columns B and C, and their total scores in column C. A retrieval area is created in columns F and G.

To do that, you need to use the INDEX operate:

=INDEX(a,b,c)

the place a is the array to scan, b is the row quantity, and c is the column quantity.

For argument b, as a result of the row modifications relying on the participant ID you enter into cell F2, you want to nest the XMATCH function, which searches for a specified merchandise and returns its relative place. And since one of the best strategy to nesting in Excel is to start out with the nested features, that is the place you need to start. So, in cell G2, kind:

=XMATCH(F2,A2:A6)

Whenever you press Enter, this method accurately returns 4, as a result of participant D is on the fourth row of the vary A2 to A6.

The XMATCH function in Excel is used to return the relative position (4) of a player ID in a dataset.

Now, this XMATCH method can act as argument b of the INDEX operate, so that you now must wrap the remainder of the INDEX arguments round XMATCH:

=INDEX(a,XMATCH(F2,A2:A6),c)

Argument c goes to be 4 since you need to return the worth from the fourth column (complete):

=INDEX(a,XMATCH(F2,A2:A6),4)

So now, all that is required is to enter argument a, and since that is the entire array to scan, it will be cells A2 to D6:

=INDEX(A2:D6,XMATCH(F2,A2:A6),4)
XMATCH nested inside INDEX in Excel to return a score of 152 for player D.

Now, while you enter a unique participant into cell F2, the nested XMATCH searches for it in cells A2 to A6, and returns its relative place for argument b of the INDEX operate.

XMATCH nested inside INDEX in Excel to return a score of 161 for player B.

To make a posh method with nested features simpler to know and parse, break up the method onto a number of strains within the method bar utilizing Alt+Enter. After doing this, click on and drag the underside of the method bar downwards so that you could see all strains of the method on the similar time.

In case you do not all the time need to return the whole within the fourth column, you can go one step additional and nest one other XMATCH method to find out the column quantity:

=INDEX(A1:D6,XMATCH(F2,A1:A6),XMATCH(G2,A1:D1))

On this case, for argument c, XMATCH takes the worth in cell G5, searches for it in cells A1 to D1, and returns its relative place.

Two nested XMATCH functions inside INDEX in Excel to return the round two score (64) of player D.

Nesting MAX Inside AVERAGE

Suppose you’ve got this spreadsheet, which incorporates 5 gamers’ scores throughout three video games, and your intention is to search out the typical of the best scores in every.

An Excel sheet containing the scores of five players across three games, with an area on the right where the highest scores for each game will be averaged.

In different phrases, you first want Excel to work out the utmost scores in cells B2 to B6, C2 to C6, and D2 to D6, respectively, earlier than averaging the consequence. So, the MAX operate must be nested contained in the AVERAGE operate.

First, arrange the three MAX nestings, making an allowance for that arguments for the AVERAGE operate are separated by a comma:

MAX(B2:B6),MAX(C2:C6),MAX(D2:D6)
Three MAX arguments are typed into cell G2 in Excel, with each referencing a column in a dataset.

Now, with Enter mode nonetheless activated, wrap the AVERAGE operate round these nested MAX formulation:

=AVERAGE(MAX(B2:B6),MAX(C2:C6),MAX(D2:D6))
Three MAX formulas nested inside AVERAGE in Excel to return the average of the maximum scores in three games.

Earlier than you nest, take a second to verify {that a} operate’s arguments haven’t got the capability to do the identical factor. For instance, you need not nest XLOOKUP inside IFERROR, as a result of XLOOKUP has its personal error-handling argument.

Nesting Capabilities Inside Themselves

To date, all of the examples have nested one operate inside one other. Nonetheless, typically, you would possibly must nest a operate inside itself. Complicated? Let me present you the way this works utilizing the IF operate.

On this worksheet, an worker’s bonus is set by the revenue they make. Particularly, income over $25,000 end in a ten% bonus, income over $20,000 return a 5% bonus, income over $10,000 yield a 2% bonus, and income over $10,000 end in a 1% bonus.

An Excel spreadsheet, with employees in column A, profits in column B, and totals in column D, with an empty bonus field in column C.

Make certain all of the related cells have the Proportion number format utilized to them so they seem as proportion values relatively than decimal numbers.

On this case, you want to nest IF to create a tiered analysis system from highest to lowest. It is because nested IF features consider from left to proper, stopping on the first situation that’s true. So, in cell C2, kind:

=IF(B2>25000,10%

however do not press Enter but. This primary part tells Excel to judge cell B2, and if it is larger than $25,000 (in different phrases, if it evaluates the logical take a look at as TRUE), return 10%. Nonetheless, you want to inform Excel what to do if it returns FALSE. On this case, you need to verify whether or not the worth in cell B2 is bigger than the second-tier worth, $20,000, returning 5% if that’s the case:

=IF(B2>25000,10%,IF(B2>20000,5%

If this nested IF operate returns FALSE, you need Excel to maneuver to the subsequent tier, so you have to nest one other IF operate:

=IF(B2>25000,10%,IF(B2>20000,5%,IF(B2>15000,2%

Now, you want to create the bottom tier by one other nested IF operate:

=IF(B2>25000,10%,IF(B2>20000,5%,IF(B2>15000,2%,IF(B2>10000,1%

Since there aren’t any extra tiers, you want to inform Excel what to return if not one of the nested IF features consider as TRUE. On this case, you need to return 0%:

=IF(B2>25000,10%,IF(B2>20000,5%,IF(B2>15000,2%,IF(B2>10000,1%,0%

Now that each one the tiers are created by nested IF features, you may shut the parentheses. There are 4 opening parentheses, so you want to kind 4 closing parentheses earlier than urgent Enter:

=IF(B2>25000,10%,IF(B2>20000,5%,IF(B2>15000,2%,IF(B2>10000,1%,0%))))

As you kind the closing parentheses, Excel briefly highlights the opening parentheses to which they correspond, and the parentheses are color-coded, which means you may shortly verify that each one pairs are full.

Nested IF functions used in Excel to return a bonus of 1 per cent based on the employee's profit of 14,088 USD.

Now you can double-click the fill deal with to use the method to the remaining cells in column C.

The fill handle of cell C2 in Excel is double-clicked to apply a formula containing nested IF functions to cells C3, 4, 5, and 6.

In Excel 2007 and later (together with Excel for Microsoft 365), you may nest as much as 64 IF features. In older variations (Excel 2003 or earlier), you may nest as much as seven.


Nesting features in Excel permits you to make the most of multiple operate’s capabilities on the similar time. The extra you profit from this method construction, the extra you may begin to study which function combinations work nicely to assist speed up your spreadsheet workflow.

OS

Home windows, macOS, iPhone, iPad, Android

Free trial

1 month

Microsoft 365 contains entry to Workplace apps like Phrase, Excel, and PowerPoint on as much as 5 gadgets, 1 TB of OneDrive storage, and extra.