--- title: "XLOOKUP and pivot tables" description: "Pull matching information from one table into another with XLOOKUP, and summarize hundreds of rows in seconds with a pivot table." updated: 2026-12-03 minutes: 11 level: Intermediate order: 2 sources: - https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929 - https://support.google.com/docs/answer/12405947 - https://support.google.com/docs/answer/1272900 - https://support.microsoft.com/en-us/office/create-a-pivottable-to-analyze-worksheet-data-a9a84538-bfe9-40a9-a8e9-f99134456576 - https://support.microsoft.com/office/refresh-pivottable-data-6d24cece-a038-468a-8176-8b6568ca9be2 - https://techcommunity.microsoft.com/blog/microsoft365insiderblog/keep-data-updated-with-pivottable-auto-refresh-in-excel/4436409 - https://support.google.com/docs/answer/7572895 --- 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. Orders Code Price V-200 48.00 Price list Code Price F-100 12.50 V-200 48.00 H-300 9.75 1. Find the code 2. Return the price from that 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". In the orders table, click the first row of the Price column. Start with `=XLOOKUP(` and click the code cell, then select the Code column in the price list, then the Price column. A fourth argument like `"Not found"` makes missing codes easy to spot instead of showing an error. 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. 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. XLOOKUP works in Microsoft 365, Excel 2021 and later, Excel for the web and Google Sheets. Excel 2019 and older do not have it. If a coworker sees errors, check which version they use. ### 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 rows Pivot Jan Feb Filter Valve 1,250 980 3,400 2,960 Sales by product and month ### Build one One header row, no blank rows, a real date in the Date column. 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. Drag or add Product to Rows. 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". 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. 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