Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Combine SUMIF and XLOOKUP in Excel: Step-by-Step Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

You can combine SUMIF and XLOOKUP in Excel by using XLOOKUP to find the lookup value, then feeding that result into SUMIF as the criteria. For example, =SUMIF(A2:A100, XLOOKUP("Widget", D2:D100, E2:E100), B2:B100) sums the values in B2:B100 for every row where column A matches the product name returned by XLOOKUP. This lets you look up a name or ID from one table and immediately total all matching amounts from another table, without hardcoding the criteria.

XLOOKUP is available in Excel for Microsoft 365, Excel 2021, and Excel for the web; it is not in Excel 2019 or earlier. SUMIF works in all modern Excel versions. If you are on an older version, use INDEX/MATCH instead of XLOOKUP. The steps below assume a recent desktop or web version; menu labels can differ slightly by version, device, or region.

What You'll Need

  • Excel for Microsoft 365, Excel 2021, or Excel for the web (XLOOKUP required).
  • Two ranges: one containing the lookup table (the values XLOOKUP will search), and one containing the data you want to sum.
  • Matching data types in the lookup columns (for example, both text or both numbers; a number stored as text will not match a real number).
  • A cell to hold the formula, and ideally a cell holding the lookup value (such as a product name) so you can change it without editing the formula.

Step-by-Step

  1. Lay out your data clearly. Put the source data you want to sum in one table (for example, columns A to C with Region, Product, and Amount). Put the lookup table in another area (for example, columns E to F with Product and Category). Keep headers in row 1 and data starting in row 2.
  2. Decide what XLOOKUP should return. XLOOKUP needs a lookup value, a lookup array, and a return array. For example, to find the category for a product in cell H2, use =XLOOKUP(H2, E2:E100, F2:F100). This returns the category name.
  3. Decide what SUMIF should sum. SUMIF needs a range to check, a criteria, and a sum range. For example, to sum amounts in C2:C100 where the product in B2:B100 matches a category, use =SUMIF(B2:B100, criteria, C2:C100).
  4. Combine them by nesting XLOOKUP as the criteria. Replace the criteria argument in SUMIF with the XLOOKUP formula: =SUMIF(B2:B100, XLOOKUP(H2, E2:E100, F2:F100), C2:C100). This sums all amounts in C2:C100 where the product in B2:B100 equals the category returned by XLOOKUP.
  5. Press Enter and check the result. The formula should return a single number. If it returns 0, verify that the XLOOKUP result exactly matches values in the SUMIF range (watch for extra spaces or text vs. number formatting).
  6. Make the ranges absolute if you plan to copy the formula. Select the ranges in the formula bar and press F4 to add dollar signs, for example $B$2:$B$100. This keeps the ranges fixed when you fill the formula down or across.
  7. Test with a different lookup value. Change the value in H2 and confirm the total updates correctly. Compare it with a manual filter or a pivot table to be sure the logic is right.
  8. Add error handling if needed. Wrap XLOOKUP in IFERROR so a missing lookup value does not break the formula: =SUMIF(B2:B100, IFERROR(XLOOKUP(H2, E2:E100, F2:F100), ""), C2:C100). An empty criteria may sum everything, so use a value that cannot match, such as "No match", if you prefer a zero result.

Common Mistakes

  • Mismatched range sizes. SUMIF's criteria range and sum range must be the same size and shape. XLOOKUP's lookup array and return array must also be the same size. If one is longer, results can be wrong or #VALUE! errors appear.
  • Text vs. number mismatch. If the lookup value is a number stored as text (often imported data), XLOOKUP may not find it or SUMIF may not match it. Convert with Text to Columns or VALUE, or use a helper column.
  • Extra spaces. Trailing spaces in either table cause silent mismatches. Use TRIM on the lookup columns or clean the data first.
  • Using XLOOKUP where a direct cell reference would do. If the criteria is already in a cell, you do not need XLOOKUP at all; just reference the cell. Nesting adds complexity and potential errors.
  • Forgetting XLOOKUP is unavailable in older Excel. In Excel 2019 or earlier, the formula returns #NAME?. Use INDEX/MATCH as the criteria instead.
  • Assuming SUMIF is case-sensitive. SUMIF is not case-sensitive, so "widget" and "Widget" match. If you need case-sensitive summing, use SUMPRODUCT with EXACT.

Tips

  • Use structured references if your data is in an Excel Table, for example . Tables auto-expand, so ranges stay correct.
  • Name your ranges (Formulas > Define Name) to make formulas easier to read and audit.
  • Use XLOOKUP's fourth argument (if_not_found) instead of IFERROR where possible: XLOOKUP(H2, E2:E100, F2:F100, "No match").
  • If you need multiple criteria, SUMIFS is the better tool; XLOOKUP can supply one criterion, but SUMIFS handles several ranges and criteria pairs.
  • Keep lookup tables sorted only if you use approximate match (match_mode 1 or -1); exact match (0) does not require sorting.
  • Document the formula with a cell comment so others know what the nested XLOOKUP is doing.

Troubleshooting

  • Formula returns 0. Check that the XLOOKUP result exactly matches a value in the SUMIF criteria range. Look for spaces, different capitalization (not an issue for SUMIF), or numbers stored as text. Test XLOOKUP alone in a cell to see what it returns.
  • #N/A from XLOOKUP. The lookup value is not in the lookup array. Confirm the value exists, check for hidden characters, and consider using wildcard match mode (2) if partial matches are intended.
  • #VALUE! error. Usually a range size mismatch. Verify that the criteria range and sum range in SUMIF are the same dimensions, and that XLOOKUP's arrays are the same size.
  • #NAME? error. XLOOKUP is not recognized, meaning your Excel version does not support it. Use INDEX/MATCH: =SUMIF(B2:B100, INDEX(F2:F100, MATCH(H2, E2:E100, 0)), C2:C100).
  • Wrong total. Compare against a filtered subtotal or pivot table. Check that the sum range is the column you intend and that no rows are excluded by the range boundaries.
  • Formula breaks when copied. Add absolute references with F4, or convert the data to a Table and use structured references.

Frequently Asked Questions

Can I use XLOOKUP inside SUMIFS?

Yes. XLOOKUP can supply one of the criteria in SUMIFS, but each criteria range in SUMIFS must be the same size. For example, =SUMIFS(C2:C100, B2:B100, XLOOKUP(H2, E2:E100, F2:F100)) works if the ranges align.

Does this work in Excel for the web?

Yes, XLOOKUP and SUMIF are both supported in Excel for the web, and the formula behaves the same as in desktop Excel for Microsoft 365.

Why does my combined formula return a #N/A error?

The #N/A comes from XLOOKUP, not SUMIF. It means the lookup value was not found in the lookup array. Check the value, the range, and for hidden spaces or text/number mismatches.

Can I use SUMIF with XLOOKUP to sum multiple columns?

SUMIF sums a single sum range. To sum multiple columns, use SUMPRODUCT or add several SUMIF formulas together, or restructure the data into a single column.

Is XLOOKUP case-sensitive?

No, XLOOKUP is not case-sensitive by default. If you need case-sensitive matching, use EXACT with SUMPRODUCT or FILTER instead.

What is the alternative if XLOOKUP is not available?

Use INDEX and MATCH to return the same value: INDEX(return_range, MATCH(lookup_value, lookup_range, 0)), then place that inside SUMIF as the criteria.