AGGREGATE
AGGREGAAT in Dutch Excel
Runs one of 19 calculations, such as SUM, LARGE or a quartile, while skipping error values, hidden rows or nested subtotals as you choose.
Last updated: 13 October 2026
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Order line | Material code | Line value | Total of priced lines | |
| 2 | OL-01 | KB-2501 | €1,250.00€ 1.250,00 | €5,825.75€ 5.825,75=AGGREGATE(9, 6, C2:C7)=AGGREGATE(9; 6; C2:C7) | |
| 3 | OL-02 | KB-2517 | #N/A | ||
| 4 | OL-03 | WP-0310 | €840.50€ 840,50 | ||
| 5 | OL-04 | WP-0388 | €3,120.00€ 3.120,00 | ||
| 6 | OL-05 | KB-2999 | #N/A | ||
| 7 | OL-06 | TH-1140 | €615.25€ 615,25 |
Swipe sideways to see all columns
Result: €5,825.75€ 5.825,75
=AGGREGATE(9,6, C2:C7)
=AGGREGATE(9;6; C2:C7)
What AGGREGATE does and when to use it
What it does: it runs a calculation such as a total or the third largest value and skips the cells you choose, for example a price column in which some lookups returned #N/A.
When to use it: when a column holds error values you cannot repair first, or hidden rows, and you still need a total or a ranking. It replaces SUBTOTAL once errors get in the way.
Three main gains:
- Skips errors: one #N/A no longer makes SUM or LARGE fail.
- Visible rows only: rows hidden by a filter drop out of the result.
- More than a total: LARGE, SMALL, percentiles and quartiles, which SUBTOTAL does not offer.
How Excel evaluates it
Excel reads function_num first and picks the calculation. It then reads options and builds the list of cells to leave out, depending on the code:
- error values
- rows hidden by a filter or by hand
- cells that hold a SUBTOTAL or AGGREGATE formula
What remains goes into the calculation. With codes 14 to 19 the last argument k is applied to that remaining set, so a rank counts only the cells that were kept.
With codes 1 to 13 the arguments after options must be references; with 14 to 19 the third argument can also be a calculated array.
Watch out: AGGREGATE hides errors without a trace. When they point to a real problem, repair the source or use IFERROR where you can see the replacement.
Mental model
A sorting table with two switches. The first picks the machine (sum, largest, quartile); the second picks what is thrown out before the machine starts.
Terms used on this page: reference, error value, array, argument, cell
AGGREGATE(function_num,options, ref1, [ref2], ...)
AGGREGATE(function_num;options; ref1; [ref2]; ...)
| Argument | Type | Meaning |
|---|---|---|
function_num | Required | 1 to 19: which calculation to run, such as 9 for SUM, 14 for LARGE. |
options | Required | 0 to 7: what to skip. 6 = errors, 5 = hidden rows, 7 = both. |
ref1 | Required | The range to calculate over (or an array, for codes 14 to 19). |
ref2 | Optional | For codes 14 to 19: k, the rank or fraction. Codes 1 to 13: more ranges. |
Return value:A number: the chosen calculation over the cells that remain
Formulas use commas (,) between arguments, as in English Excel. Formulas use semicolons (;) between arguments, as in Dutch Excel. Formulas use commas (,) between arguments, as in English Excel; Dutch Excel uses semicolons (;).
Worked examples
Beginner
Total of order lines whose price lookup failed on some rows
You are auditing the purchase commitments of Veldhuis Installatie BV. Column C holds the line value that a lookup retrieves from the client's price list; the lookup returns #N/A for material codes that are missing from that list. You want the total of the lines that did get a price, without first repairing every lookup.
| Row | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| 1 | Order line | Material code | Line value | Total of priced lines | ||
| 2 | OL-01 | KB-2501 | €1,250.00€ 1.250,00 | €5,825.75€ 5.825,75=AGGREGATE(9, 6, C2:C7)=AGGREGATE(9; 6; C2:C7) | ||
| 3 | OL-02 | KB-2517 | #N/A | |||
| 4 | OL-03 | WP-0310 | €840.50€ 840,50 | |||
| 5 | OL-04 | WP-0388 | €3,120.00€ 3.120,00 | |||
| 6 | OL-05 | KB-2999 | #N/A | |||
| 7 | OL-06 | TH-1140 | €615.25€ 615,25 | |||
| 8 |
Swipe sideways to see all columns
Formula in E2
=AGGREGATE(9,6, C2:C7)
=AGGREGATE(9;6; C2:C7)
Result: €5,825.75€ 5.825,75
Step by step
- function_num is 9, the code for SUM. options is 6: skip cells that contain an error value. Hidden rows and nested subtotals are not part of option 6.
- AGGREGATE goes through
C2:C7, six cells: 1250, #N/A, 840.50, 3120, #N/A, 615.25. C3andC6hold #N/A, so option 6 sets them aside. Four cells remain:C2,C4,C5andC7.- The four values go into SUM: 1250 + 840.50 + 3120 + 615.25 = 5825.75.
- Fix the price for
OL-02and its value joins the total at once. SUM(C2:C7) on the same range would return #N/A as soon as one error is present.
Watch out: The total looks complete but leaves out two order lines. Skipping errors is silent, so count the error cells (Go To Special > Formulas > Errors) and report them as unpriced lines.
More on this example: why it works, 1 more pitfall, 1 variation
Why it works
The options argument decides what is skipped before the calculation starts, so the SUM only ever sees numbers. The calculation itself is the ordinary SUM.
More to watch out for
- Option 6 does not skip rows hidden by a filter. Use 7 if the visible rows are what you want.
Variations
=SUM(IFERROR(C2:C7,0))
=SUM(IFERROR(C2:C7;0))
Same total, 5825.75. In Excel 2019 and earlier you confirm it with Ctrl+Shift+Enter. Prefer it when you want to see the replacement value in the formula.
Intermediate
Third largest posting while some imported amounts are errors
For a journal entry test at Veldhuis Installatie BV, the amounts of a year-end import landed in column B. Two cells show errors because the import could not convert them. You want the third largest amount to pick the postings to inspect first, and the rank must be changeable in a cell.
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Entry | Amount | Rank (k) | Amount at that rank | |||
| 2 | JE-101 | €18,400.00€ 18.400,00 | 33 | €29,875.00€ 29.875,00=AGGREGATE(14, 6, B2:B8, D2)=AGGREGATE(14; 6; B2:B8; D2) | |||
| 3 | JE-102 | €42,150.00€ 42.150,00 | |||||
| 4 | JE-103 | #VALUE! | |||||
| 5 | JE-104 | €7,300.00€ 7.300,00 | |||||
| 6 | JE-105 | €42,150.00€ 42.150,00 | |||||
| 7 | JE-106 | €29,875.00€ 29.875,00 | |||||
| 8 | JE-107 | #DIV/0! | |||||
| 9 |
Swipe sideways to see all columns
Formula in F2
=AGGREGATE(14,6, B2:B8, D2)
=AGGREGATE(14;6; B2:B8; D2)
Result: €29,875.00€ 29.875,00
Step by step
- function_num 14 is LARGE, which needs a k. options 6 skips error values. The k is the fourth argument,
D2, which holds 3. - AGGREGATE reads
B2:B8and finds #VALUE! inB4and #DIV/0! inB8. Both are set aside. - Five numbers remain: 18400, 42150, 7300, 42150, 29875. Sorted from large to small: 42150, 42150, 29875, 18400, 7300.
- The two entries of 42150 take rank 1 and rank 2, so rank 3 is 29875.
- Type 6 in
D2and the result is #NUM!: only five numbers are left, so there is no sixth largest.
Watch out: The result is the third largest entry, not the third largest distinct amount. With 42150 twice, rank 2 is still 42150.
More on this example: why it works, 1 more pitfall, 2 variations
Why it works
Codes 14 to 19 take a fourth argument, k, which is read after the errors have been removed. Rank therefore counts only real numbers, and a duplicate amount occupies as many ranks as it has entries.
More to watch out for
- Leave out k with code 14 and AGGREGATE returns #VALUE!, because LARGE has no default rank.
Variations
=LARGE(IF(ISNUMBER(B2:B8),B2:B8), D2)
=LARGE(IF(ISNUMBER(B2:B8);B2:B8); D2)
Same result. It works in every version once confirmed with Ctrl+Shift+Enter, but it is longer and breaks if you forget that step.
=LARGE(FILTER(B2:B8,ISNUMBER(B2:B8)), D2)
=LARGE(FILTER(B2:B8;ISNUMBER(B2:B8)); D2)
Microsoft 365 and Excel 2021. Prefer it when you also need the cleaned list for other calculations.
Advanced
Largest invoice of one cost center, without MAXIFS
In the purchase invoices of Veldhuis Installatie BV you want the largest invoice booked on the cost center in E2, to see whether the approval limit was respected. The workbook must also open in Excel 2010, which has no MAXIFS (nor has Excel 2016 without Microsoft 365; MAXIFS starts with Excel 2019). A cell with a cost center code is the only thing you change.
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Cost center | Document | Amount | Cost center | Largest invoice | ||
| 2 | CC-20 | INV-501 | €4,820.00€ 4.820,00 | CC-20 | €9,360.00€ 9.360,00=AGGREGATE(14, 6, C2:C8 / (A2:A8 = E2), 1)=AGGREGATE(14; 6; C2:C8 / (A2:A8 = E2); 1) | ||
| 3 | CC-10 | INV-502 | €1,275.50€ 1.275,50 | ||||
| 4 | CC-20 | INV-503 | €9,360.00€ 9.360,00 | ||||
| 5 | CC-30 | INV-504 | €2,210.00€ 2.210,00 | ||||
| 6 | CC-20 | INV-505 | €7,745.25€ 7.745,25 | ||||
| 7 | CC-10 | INV-506 | €15,890.00€ 15.890,00 | ||||
| 8 | CC-30 | INV-507 | €640.00€ 640,00 | ||||
| 9 |
Swipe sideways to see all columns
Formula in F2
=AGGREGATE(14,6, C2:C8 / (A2:A8 = E2), 1)
=AGGREGATE(14;6; C2:C8 / (A2:A8 = E2); 1)
Result: €9,360.00€ 9.360,00
Step by step
- Inside out:
A2:A8=E2compares each cost center withCC-20. The result is TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE. C2:C8/ (that array) divides each amount by 1 where TRUE and by 0 where FALSE. Result: 4820, #DIV/0!, 9360, #DIV/0!, 7745.25, #DIV/0!, #DIV/0!.- AGGREGATE receives that array with code 14 (LARGE), option 6 (skip errors) and k = 1.
- Option 6 removes the four #DIV/0! values. The three invoices of
CC-20remain: 4820, 9360, 7745.25. - The largest of those is 9360. The 15890 of
CC-10is larger than everyCC-20amount, but the division by 0 turned it into an error and it was skipped. - Change
E2toCC-30and the result is 2210 (against 640).
Watch out: A matching row with a blank amount is divided as 0 / 1 = 0 and counts as a value. If every matching amount is negative, such as credit notes, a blank cell wins as the largest with 0, and nothing looks wrong.
More on this example: why it works, 2 more pitfalls, 2 variations
Why it works
Dividing by a condition turns every non-matching row into an error, and the error-skipping option then acts as the filter. The array form of AGGREGATE evaluates such a calculation itself, so no Ctrl+Shift+Enter is needed.
More to watch out for
- If no row matches, every value is an error and the result is #NUM!. That is correct but not a clear message; wrap the formula in IFERROR only if you can tell 'no match' from a real problem.
- Hidden rows are not skipped here, even with option 7, because the array after the division carries no row information.
Variations
=MAXIFS(C2:C8,A2:A8, E2)
=MAXIFS(C2:C8;A2:A8; E2)
Same result, 9360. Shorter and clearer in Excel 2019 and later; use it unless the file must work in Excel 2010, 2013 or 2016.
=MAX(FILTER(C2:C8,A2:A8 = E2))
=MAX(FILTER(C2:C8;A2:A8 = E2))
Microsoft 365 and Excel 2021. Prefer it when you also want to see the matching rows.
MasterExcel 2021 or later (This example needs Excel 2021 or later)
Upper fence for testing outliers, skipping errors and hidden test rows
In the journal entries of Veldhuis Installatie BV you set a threshold for unusual amounts: the third quartile plus 1.5 times the interquartile range. The list contains one #N/A and one test posting of 52000 that you hid by hand. Both must stay out of the quartiles, because either would distort the threshold.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Entry | Amount | Upper fence | ||
| 2 | JE-201 | €1,200.00€ 1.200,00 | €2,159.38€ 2.159,38=LET( amounts, B2:B9, lowq, AGGREGATE(17, 7, amounts, 1), highq, AGGREGATE(17, 7, amounts, 3), ROUND(highq + 1.5 * (highq - lowq), 2) )=LET( amounts; B2:B9; lowq; AGGREGATE(17; 7; amounts; 1); highq; AGGREGATE(17; 7; amounts; 3); ROUND(highq + 1,5 * (highq - lowq); 2) ) | ||
| 3 | JE-202 | €1,450.00€ 1.450,00 | |||
| 4 | JE-203 | #N/A | |||
| 5 | JE-204 | €1,325.00€ 1.325,00 | |||
| 6 (Hidden or filtered row) | JE-205 | €52,000.00€ 52.000,00 | |||
| 7 | JE-206 | €1,580.00€ 1.580,00 | |||
| 8 | JE-207 | €9,800.00€ 9.800,00 | |||
| 9 | JE-208 | €1,710.00€ 1.710,00 | |||
| 10 |
Swipe sideways to see all columns
Formula in D2
=LET( amounts,B2:B9, lowq, AGGREGATE(17, 7, amounts, 1), highq, AGGREGATE(17, 7, amounts, 3), ROUND(highq + 1.5 * (highq - lowq), 2) )
=LET( amounts;B2:B9; lowq; AGGREGATE(17; 7; amounts; 1); highq; AGGREGATE(17; 7; amounts; 3); ROUND(highq + 1,5 * (highq - lowq); 2) )
Result: €2,159.38€ 2.159,38
Step by step
- LET names the range amounts,
B2:B9. It stays a reference, which AGGREGATE needs to see which rows are hidden. - lowq is AGGREGATE(17, 7, amounts, 1). Code 17 is QUARTILE.INC, option 7 skips errors and hidden rows.
B4(#N/A) and row 6 (52000) drop out. Sorted: 1200, 1325, 1450, 1580, 1710, 9800. - The first quartile sits at position 1 + 5 × 0.25 = 2.25: 1325 + 0.25 × (1450 - 1325) = 1356.25.
- highq uses k = 3, position 1 + 5 × 0.75 = 4.75: 1580 + 0.75 × (1710 - 1580) = 1677.50.
- The interquartile range is 1677.50 - 1356.25 = 321.25. The fence is 1677.50 + 1.5 × 321.25 = 1677.50 + 481.875 = 2159.375, which ROUND makes 2159.38.
- Entry
JE-207of 9800 lies above 2159.38 and is selected for testing. Unhide row 6 and switch to option 6, and the fence jumps to 12306.25, which lets 9800 pass unnoticed.
Watch out: A different mistake: with option 6 instead of 7 the hidden 52000 counts. Q1 becomes 1387.50, Q3 5755 and the fence 12306.25. The formula still returns a number, so nothing signals the error.
More on this example: why it works, 3 more pitfalls, 1 variation
Why it works
LET names the range once, so both quartiles read the same reference and each AGGREGATE call applies option 7 to it. Option 7 combines two filters that a plain QUARTILE.INC cannot offer, and codes 14 to 19 are the only ones that give percentiles and quartiles with that choice of skipping.
Watch out for
A different mistake: with option 6 instead of 7 the hidden 52000 counts. Q1 becomes 1387.50, Q3 5755 and the fence 12306.25. The formula still returns a number, so nothing signals the error.
For the same reason, record the view in which you ran the test: unhiding a row or clearing a filter changes the result without a warning.
- Option 4 or 5 does not skip the #N/A, so the whole formula returns #N/A.
On Microsoft 365 or Excel 2021, FILTER(B2:B9, ISNUMBER(B2:B9)) gives a visible cleaned list that you can reuse for any statistic, but it does not recognize hidden rows.
The AGGREGATE part of this formula works from Excel 2010 and sees hidden rows, while the LET around it needs Excel 2021 or Microsoft 365 (without LET, repeat
B2:B9in both calls).If the errors come from a lookup, wrap the lookup in IFNA instead, so the problem is dealt with where it starts.
Variations
=LET( amounts,B2:B9, lowq, AGGREGATE(17, 6, amounts, 1), highq, AGGREGATE(17, 6, amounts, 3), ROUND(highq + 1.5 * (highq - lowq), 2) )
=LET( amounts;B2:B9; lowq; AGGREGATE(17; 6; amounts; 1); highq; AGGREGATE(17; 6; amounts; 3); ROUND(highq + 1,5 * (highq - lowq); 2) )
Option 6 returns 12306.25 here, because the hidden 52000 is included. Use it only when hidden rows are part of the population.
Common mistakes
| Symptom | Cause | Fix |
|---|---|---|
| A total that looks fine but misses rows | The result looks fine, but rows are missing from the total: option 6 skipped the errors without any message. | Count the error cells separately and report them. Fix the cause when the errors are not expected. |
| Subtotal rows counted twice | Using option 6 on a list with SUBTOTAL rows counts the subtotals twice. | Only options 0 to 3 skip nested SUBTOTAL and AGGREGATE formulas. Use 2 to skip errors and subtotals, or 3 to skip hidden rows as well. |
| #VALUE! with a calculated array | Using a code from 1 to 13 with a calculated array returns #VALUE!. | Pass a range reference, or switch to a code from 14 to 19, which accept arrays. |
| Hidden columns still in the total | Hidden columns are expected to be skipped, but the totals still include them. | The hidden-row options work on rows only. Move the data to a vertical layout or total the visible columns another way. |
| #NUM! although the range holds numbers | The result is #NUM!, although the range holds numbers. | After skipping, fewer cells remained than k asks for, or none at all. Check k and the options. |