Home / Knowledge work / Spreadsheets

XLOOKUP and pivot tables

Pull matching information from one table into another with XLOOKUP, and summarize hundreds of rows in seconds with a pivot table.

Intermediate · 11 min read · Updated December 3, 2026

Once your data is in clean tables, two tools save more time than anything else. XLOOKUP finds a value in one table and brings back related information. Pivot tables turn a long list into a short summary, like sales by month or hours by job. Both work in current Excel and Google Sheets.

XLOOKUP: find it and bring it back

Picture two tables. One is a list of orders with a product code. The other is a price list with product codes and prices. You want each order to show the right price. XLOOKUP does that.

OrdersCodePriceV-20048.00Price listCodePriceF-10012.50V-20048.00H-3009.751. Find the code2. Return the price from that row
XLOOKUP takes the code from the order, finds it in the price list, and returns the price from the same row.

The formula

=XLOOKUP(what_to_find, where_to_look, what_to_return, if_not_found)

For our example, with the order code in A2, price list codes in Prices!A2:A500 and prices in Prices!B2:B500:

=XLOOKUP(A2, Prices!A2:A500, Prices!B2:B500, "Not found")

In plain English: take the code in A2, look for it in the Code column of the Prices sheet, and return the value from the Price column on the same row. If it is not there, show "Not found".

  1. Click the first empty cell

    In the orders table, click the first row of the Price column.
  2. Type the formula

    Start with =XLOOKUP( and click the code cell, then select the Code column in the price list, then the Price column.
  3. Add the not found message

    A fourth argument like "Not found" makes missing codes easy to spot instead of showing an error.
  4. Lock the ranges and fill down

    Add dollar signs to the lookup ranges, like Prices!$A$2:$A$500, so they stay put. Then fill the formula down. If both lists are formatted as tables, you can use column names instead and skip the dollar signs.
  5. Spot check

    Pick three rows and check the price against the price list by eye.

Why XLOOKUP and not VLOOKUP

You will still see older spreadsheets that use VLOOKUP. XLOOKUP replaces it and is better in every way that matters: it can look left or right, it does exact matches by default, it does not break when someone inserts a column, and it has a built-in "not found" option. Use XLOOKUP for new work. If you inherit a file full of VLOOKUP, it still works, but switch formulas to XLOOKUP when you edit them.

When lookups fail

  • Extra spaces. "V-200 " with a trailing space does not match "V-200". Clean with =TRIM(A2).
  • Numbers stored as text in one table and as numbers in the other. Make both the same type.
  • Duplicates in the lookup column. XLOOKUP returns the first match only. Codes in a lookup list should be unique.

Pivot tables: summarize in seconds

You have 2,000 rows of sales. Your boss asks: "How much did we sell each month, by product?" You could write dozens of SUMIF formulas, or build a pivot table in under a minute.

A pivot table groups rows and adds them up. You choose:

  • Rows: what to list down the side (like Product)
  • Columns: what to list across the top (like Month)
  • Values: what to add up or count (like sum of Sales)
  • Filters: what to include (like only one region)
2,000 sales rowsPivotJanFebFilterValve1,2509803,4002,960Sales by product and month
A pivot table turns a long list into a small summary grid.

Build one

  1. Start from a clean table

    One header row, no blank rows, a real date in the Date column.
  2. Insert the pivot table

    Click a cell in the data. In Excel choose Insert, then PivotTable. In Google Sheets choose Insert, then Pivot table. Put it on a new sheet.
  3. Add rows

    Drag or add Product to Rows.
  4. Add values

    Add Sales to Values. Make sure it says SUM, not COUNT. Count is useful when you want "how many orders" instead of "how much money".
  5. Add columns

    Add Date to Columns. Group dates by month: in Excel, right-click a date and choose Group, then Months. In Sheets, right-click a date and choose Create pivot date group, then Year-Month, so January of two different years stays separate.
  6. Check one number

    Pick one cell in the summary and check it with a filter on the original data. If they match, you can trust it.

Keep it up to date

Newer Microsoft 365 versions of Excel have an Auto Refresh button on the PivotTable Analyze tab that updates a pivot when its source data changes. If your Excel does not have it, or it is off, click inside the pivot and choose Refresh (or Data, then Refresh All). Google Sheets pivot tables update automatically. If your source is a table, new rows are included when you refresh.

Getting AI help

Copilot in Excel and Gemini in Sheets can suggest formulas and build pivot summaries from a plain question like "show total sales by product by month". You can also ask Claude or ChatGPT to explain a long formula one piece at a time. Always check one or two results by hand.

Common mistakes

  • Using VLOOKUP for new work when XLOOKUP is available
  • Forgetting to lock lookup ranges before filling down
  • A pivot that counts instead of sums
  • Dates stored as text, so they will not group by month
  • Forgetting to refresh an Excel pivot after adding data when Auto Refresh is off or not available