Excel XLOOKUP Sum All Matches: Step-by-Step Guide
In this article
XLOOKUP on its own returns only the first match. To sum every value that matches a lookup key, wrap XLOOKUP in SUM and point its return_array at the full column of numbers — or, more reliably, use SUMIFS, which is built for this exact job. The shortest working formula is =SUMIFS(SumRange, LookupRange, LookupValue). If you specifically want XLOOKUP's flexibility (reverse search, wildcards, exact-or-next), use =SUM(XLOOKUP(Key, LookupRange, SumRange, 0, 0, 1)) — the final 1 tells XLOOKUP to search all matches rather than stopping at the first. This guide shows both, explains when each is right, and covers the errors that trip people up.
What You'll Need
- Microsoft Excel 365, Excel 2021, or Excel 2024 (XLOOKUP is not in Excel 2019 or earlier).
- A table with a lookup column (names, IDs, dates) and a numeric column you want to total.
- The lookup value you want to sum — either typed into a cell or hard-coded in the formula.
- Basic comfort with cell references and the difference between relative and absolute references (the $ sign).
Step-by-Step
- Lay out your data cleanly. Put the lookup column (e.g. Product) in one column and the values to sum (e.g. Amount) in another. Avoid blank rows inside the range — they break both SUMIFS and the array form of XLOOKUP. If your data has headers, note the exact header names; structured references (Table[Column]) work well and resize automatically.
- Decide which function fits. Use SUMIFS when you only need to total values by one or more criteria (the common case). Use the SUM+XLOOKUP array form when you need XLOOKUP's special behaviour — searching bottom-to-top, using wildcards, or matching approximately. For a plain "sum all matches by name", SUMIFS is faster to write and easier to audit.
- Write the SUMIFS version. Click the cell where the total should appear and type
=SUMIFS(. Select the numeric column (the values to add) and press F4 to lock it, e.g.$C$2:$C$100. Type a comma, select the lookup column and lock it, e.g.$A$2:$A$100. Type a comma, then click the cell holding your lookup value (or type it in quotes, e.g."Widget"). Close the bracket and press Enter. Example:=SUMIFS($C$2:$C$100,$A$2:$A$100,F2). - Write the SUM+XLOOKUP version. In a blank cell type
=SUM(XLOOKUP(. Select or type the lookup value, then a comma, then the lookup column, a comma, then the sum column. Add,0,0,1)— the not-found argument (0 returns zero instead of #N/A), the match mode (0 = exact match), and the search mode (1 = search all matches, which is what makes XLOOKUP return an array). Close with one more bracket for SUM. Example:=SUM(XLOOKUP(F2,$A$2:$A$100,$C$2:$C$100,0,0,1)). In Excel 365 this spills correctly; in older dynamic-array-less versions you may need to enter it with Ctrl+Shift+Enter. - Test with a known value. Pick a lookup value you can count by hand — filter the source column to that value and check the visible total matches your formula. If it does not, the ranges are misaligned or a criterion is text-vs-number.
- Copy down safely. If you are filling the formula down a list of lookup values, lock the data ranges with $ (as shown) but leave the lookup cell relative (F2, not $F$2) so each row uses its own key.
- Convert to a Table for robustness. Select the data and press Ctrl+T. Then you can write , which expands automatically as rows are added — no need to edit range ends.
Common Mistakes
- Using plain XLOOKUP without SUM. XLOOKUP alone returns the first match only, so the total looks plausible but is wrong. Always wrap it in SUM or use SUMIFS.
- Forgetting the final 1 in XLOOKUP. The sixth argument (search mode) must be 1 for "search all". Leaving it out or using 0 returns only the first match, and SUM then sums a single value.
- Mismatched range sizes. SUMIFS requires all ranges to be the same height and width. A common cause of #VALUE! is one range ending at row 100 and another at row 101.
- Text vs number mismatch. If the lookup column stores IDs as text (e.g. "00123") but the lookup value is a number (123), SUMIFS returns 0. Use VALUE() or TEXT() to align, or fix the source formatting.
- Wildcards behaving unexpectedly. SUMIFS treats * and ? as wildcards. If your data contains literal asterisks, escape them with ~ or switch to the XLOOKUP array form with match mode 2.
- Not locking ranges before copying. Without $, the ranges shift as you drag down and totals silently drift.
- Blank rows inside the range. They do not break SUMIFS but can break array behaviour and make auditing confusing — clean the data first.
Tips
- Use SUMIFS for multiple criteria:
=SUMIFS(SumRange, Col1, Crit1, Col2, Crit2)adds an AND condition, e.g. sum by product and by month. - For an OR-style total (sum if the key matches A or B), add two SUMIFS:
=SUMIFS(..."A")+SUMIFS(..."B"). - Prefer structured references (Table[Column]) — they are self-documenting and resize automatically.
- Name your ranges (Formulas > Define Name) to make formulas readable:
=SUMIFS(Amount,Product,F2). - If you need a running total by key, combine SUMIFS with an expanding range:
=SUMIFS($C$2:C2,$A$2:A2,A2). - Check the result with a PivotTable (Insert > PivotTable) as a cross-check — it groups and sums by key without formulas.
Troubleshooting
- Result is 0 when you expect a total. Check for text-vs-number mismatch, trailing spaces (use TRIM), or a lookup value that does not exactly match. Test with a value you can see in the column.
- #VALUE! error. Usually mismatched range sizes in SUMIFS, or a non-numeric sum range. Confirm all ranges are the same dimensions and the sum column contains numbers.
- #N/A with XLOOKUP. The lookup value is not found. Add the fourth argument (0) to return zero instead, or wrap in IFERROR.
- #NAME? error. XLOOKUP is not available in your Excel version, or the function name is misspelled. Check File > Account > About Excel; if XLOOKUP is missing, use SUMIFS instead.
- Formula returns only the first match. You forgot the final 1 in XLOOKUP, or you used plain XLOOKUP without SUM. Fix the search mode or switch to SUMIFS.
- Totals change when you sort or add rows. Ranges were not locked or not converted to a Table. Lock with $ or press Ctrl+T.
- Spill error (#SPILL!). The array result from SUM+XLOOKUP has nowhere to expand. Clear the cells below, or wrap the whole thing in SUM (which you already are) and confirm you closed all brackets.
Frequently Asked Questions
Can XLOOKUP sum multiple matches on its own?
No. XLOOKUP returns values, not sums. You must wrap it in SUM and set the search mode to 1, or use SUMIFS, which is designed for conditional totals.
Which is better, SUMIFS or SUM+XLOOKUP?
For simple "sum all values matching this key", SUMIFS is simpler, faster, and works in more Excel versions. Use SUM+XLOOKUP when you need reverse search, wildcards, or approximate matching.
Why does my SUMIFS return 0?
Almost always a text-vs-number mismatch or hidden spaces. Check the lookup column's format and use TRIM or VALUE to clean the data.
Does this work in Excel 2019?
SUMIFS works in all modern Excel versions. XLOOKUP requires Excel 365, Excel 2021, or Excel 2024. In older versions, use SUMIFS or INDEX/MATCH with SUM as an array formula.
Can I sum with multiple criteria?
Yes — SUMIFS accepts additional criteria pairs: =SUMIFS(SumRange, Col1, Crit1, Col2, Crit2). Each pair is an AND condition.
How do I sum all matches across two columns?
Use two SUMIFS added together, or SUMIFS with a helper column that concatenates the two keys. Avoid summing overlapping ranges, which double-counts.