Become a Pro / website · becomeapro.ai / content / lessons / knowledge-work / spreadsheets / xlookup-and-pivot-tables.mdx
| 1 | --- |
| 2 | title: "XLOOKUP and pivot tables" |
| 3 | description: "Pull matching information from one table into another with XLOOKUP, and summarize hundreds of rows in seconds with a pivot table." |
| 4 | updated: 2026-12-03 |
| 5 | minutes: 11 |
| 6 | level: Intermediate |
| 7 | order: 2 |
| 8 | sources: |
| 9 | - https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929 |
| 10 | - https://support.google.com/docs/answer/12405947 |
| 11 | - https://support.google.com/docs/answer/1272900 |
| 12 | - https://support.microsoft.com/en-us/office/create-a-pivottable-to-analyze-worksheet-data-a9a84538-bfe9-40a9-a8e9-f99134456576 |
| 13 | - https://support.microsoft.com/office/refresh-pivottable-data-6d24cece-a038-468a-8176-8b6568ca9be2 |
| 14 | - https://techcommunity.microsoft.com/blog/microsoft365insiderblog/keep-data-updated-with-pivottable-auto-refresh-in-excel/4436409 |
| 15 | - https://support.google.com/docs/answer/7572895 |
| 16 | --- |
| 17 | |
| 18 | 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. |
| 19 | |
| 20 | ## XLOOKUP: find it and bring it back |
| 21 | |
| 22 | 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. |
| 23 | |
| 24 | <Diagram caption="XLOOKUP takes the code from the order, finds it in the price list, and returns the price from the same row."> |
| 25 | <svg viewBox="0 0 600 270" role="img" aria-label="XLOOKUP diagram: an order code is matched in a price list and the matching price is returned"> |
| 26 | <text x="130" y="28" fontSize="16" textAnchor="middle" fill="currentColor">Orders</text> |
| 27 | <rect x="30" y="40" width="200" height="36" className="soft" stroke="currentColor" strokeWidth="2" /> |
| 28 | <text x="80" y="64" fontSize="14" textAnchor="middle" fill="currentColor">Code</text> |
| 29 | <text x="180" y="64" fontSize="14" textAnchor="middle" fill="currentColor">Price</text> |
| 30 | <rect x="30" y="76" width="200" height="36" fill="none" stroke="currentColor" strokeWidth="2" /> |
| 31 | <line x1="130" y1="40" x2="130" y2="112" stroke="currentColor" strokeWidth="1" /> |
| 32 | <text x="80" y="100" fontSize="14" textAnchor="middle" fill="currentColor">V-200</text> |
| 33 | <text x="180" y="100" fontSize="14" textAnchor="middle" fill="currentColor">48.00</text> |
| 34 | <text x="470" y="28" fontSize="16" textAnchor="middle" fill="currentColor">Price list</text> |
| 35 | <rect x="370" y="40" width="200" height="36" className="soft" stroke="currentColor" strokeWidth="2" /> |
| 36 | <text x="420" y="64" fontSize="14" textAnchor="middle" fill="currentColor">Code</text> |
| 37 | <text x="520" y="64" fontSize="14" textAnchor="middle" fill="currentColor">Price</text> |
| 38 | <rect x="370" y="76" width="200" height="108" fill="none" stroke="currentColor" strokeWidth="2" /> |
| 39 | <line x1="470" y1="40" x2="470" y2="184" stroke="currentColor" strokeWidth="1" /> |
| 40 | <line x1="370" y1="112" x2="570" y2="112" stroke="currentColor" strokeWidth="1" /> |
| 41 | <line x1="370" y1="148" x2="570" y2="148" stroke="currentColor" strokeWidth="1" /> |
| 42 | <text x="420" y="100" fontSize="14" textAnchor="middle" fill="currentColor">F-100</text> |
| 43 | <text x="520" y="100" fontSize="14" textAnchor="middle" fill="currentColor">12.50</text> |
| 44 | <text x="420" y="136" fontSize="14" textAnchor="middle" fill="currentColor">V-200</text> |
| 45 | <text x="520" y="136" fontSize="14" textAnchor="middle" fill="currentColor">48.00</text> |
| 46 | <text x="420" y="172" fontSize="14" textAnchor="middle" fill="currentColor">H-300</text> |
| 47 | <text x="520" y="172" fontSize="14" textAnchor="middle" fill="currentColor">9.75</text> |
| 48 | <path d="M80 112 L80 220 L420 220 L420 150" fill="none" stroke="currentColor" strokeWidth="2" strokeDasharray="6 4" /> |
| 49 | <text x="250" y="244" fontSize="14" textAnchor="middle" fill="currentColor">1. Find the code</text> |
| 50 | <path d="M520 112 L520 10 L180 10 L180 76" fill="none" stroke="currentColor" strokeWidth="2" /> |
| 51 | <text x="300" y="264" fontSize="14" textAnchor="middle" fill="currentColor">2. Return the price from that row</text> |
| 52 | </svg> |
| 53 | </Diagram> |
| 54 | |
| 55 | ### The formula |
| 56 | |
| 57 | ``` |
| 58 | =XLOOKUP(what_to_find, where_to_look, what_to_return, if_not_found) |
| 59 | ``` |
| 60 | |
| 61 | For our example, with the order code in A2, price list codes in `Prices!A2:A500` and prices in `Prices!B2:B500`: |
| 62 | |
| 63 | ``` |
| 64 | =XLOOKUP(A2, Prices!A2:A500, Prices!B2:B500, "Not found") |
| 65 | ``` |
| 66 | |
| 67 | 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". |
| 68 | |
| 69 | <Steps> |
| 70 | <Step title="Click the first empty cell">In the orders table, click the first row of the Price column.</Step> |
| 71 | <Step title="Type the formula">Start with `=XLOOKUP(` and click the code cell, then select the Code column in the price list, then the Price column.</Step> |
| 72 | <Step title="Add the not found message">A fourth argument like `"Not found"` makes missing codes easy to spot instead of showing an error.</Step> |
| 73 | <Step title="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.</Step> |
| 74 | <Step title="Spot check">Pick three rows and check the price against the price list by eye.</Step> |
| 75 | </Steps> |
| 76 | |
| 77 | ### Why XLOOKUP and not VLOOKUP |
| 78 | |
| 79 | 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. |
| 80 | |
| 81 | <Callout type="note">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.</Callout> |
| 82 | |
| 83 | ### When lookups fail |
| 84 | |
| 85 | - **Extra spaces.** "V-200 " with a trailing space does not match "V-200". Clean with `=TRIM(A2)`. |
| 86 | - **Numbers stored as text** in one table and as numbers in the other. Make both the same type. |
| 87 | - **Duplicates** in the lookup column. XLOOKUP returns the first match only. Codes in a lookup list should be unique. |
| 88 | |
| 89 | ## Pivot tables: summarize in seconds |
| 90 | |
| 91 | 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. |
| 92 | |
| 93 | A pivot table groups rows and adds them up. You choose: |
| 94 | |
| 95 | - **Rows:** what to list down the side (like Product) |
| 96 | - **Columns:** what to list across the top (like Month) |
| 97 | - **Values:** what to add up or count (like sum of Sales) |
| 98 | - **Filters:** what to include (like only one region) |
| 99 | |
| 100 | <Diagram caption="A pivot table turns a long list into a small summary grid."> |
| 101 | <svg viewBox="0 0 600 230" role="img" aria-label="A long list of rows on the left becomes a small summary grid on the right"> |
| 102 | <rect x="30" y="20" width="160" height="190" fill="none" stroke="currentColor" strokeWidth="2" /> |
| 103 | <line x1="30" y1="44" x2="190" y2="44" stroke="currentColor" strokeWidth="1" /> |
| 104 | <line x1="30" y1="68" x2="190" y2="68" stroke="currentColor" strokeWidth="1" /> |
| 105 | <line x1="30" y1="92" x2="190" y2="92" stroke="currentColor" strokeWidth="1" /> |
| 106 | <line x1="30" y1="116" x2="190" y2="116" stroke="currentColor" strokeWidth="1" /> |
| 107 | <line x1="30" y1="140" x2="190" y2="140" stroke="currentColor" strokeWidth="1" /> |
| 108 | <line x1="30" y1="164" x2="190" y2="164" stroke="currentColor" strokeWidth="1" /> |
| 109 | <line x1="30" y1="188" x2="190" y2="188" stroke="currentColor" strokeWidth="1" /> |
| 110 | <text x="110" y="226" fontSize="14" textAnchor="middle" fill="currentColor">2,000 sales rows</text> |
| 111 | <line x1="210" y1="115" x2="320" y2="115" stroke="currentColor" strokeWidth="2" /> |
| 112 | <path d="M310 107 L322 115 L310 123" fill="none" stroke="currentColor" strokeWidth="2" /> |
| 113 | <text x="265" y="100" fontSize="14" textAnchor="middle" fill="currentColor">Pivot</text> |
| 114 | <rect x="340" y="50" width="230" height="36" className="soft" stroke="currentColor" strokeWidth="2" /> |
| 115 | <rect x="340" y="86" width="230" height="72" fill="none" stroke="currentColor" strokeWidth="2" /> |
| 116 | <line x1="340" y1="122" x2="570" y2="122" stroke="currentColor" strokeWidth="1" /> |
| 117 | <line x1="420" y1="50" x2="420" y2="158" stroke="currentColor" strokeWidth="1" /> |
| 118 | <line x1="495" y1="50" x2="495" y2="158" stroke="currentColor" strokeWidth="1" /> |
| 119 | <text x="458" y="74" fontSize="14" textAnchor="middle" fill="currentColor">Jan</text> |
| 120 | <text x="532" y="74" fontSize="14" textAnchor="middle" fill="currentColor">Feb</text> |
| 121 | <text x="380" y="110" fontSize="14" textAnchor="middle" fill="currentColor">Filter</text> |
| 122 | <text x="380" y="146" fontSize="14" textAnchor="middle" fill="currentColor">Valve</text> |
| 123 | <text x="458" y="110" fontSize="14" textAnchor="middle" fill="currentColor">1,250</text> |
| 124 | <text x="532" y="110" fontSize="14" textAnchor="middle" fill="currentColor">980</text> |
| 125 | <text x="458" y="146" fontSize="14" textAnchor="middle" fill="currentColor">3,400</text> |
| 126 | <text x="532" y="146" fontSize="14" textAnchor="middle" fill="currentColor">2,960</text> |
| 127 | <text x="455" y="190" fontSize="14" textAnchor="middle" fill="currentColor">Sales by product and month</text> |
| 128 | </svg> |
| 129 | </Diagram> |
| 130 | |
| 131 | ### Build one |
| 132 | |
| 133 | <Steps> |
| 134 | <Step title="Start from a clean table">One header row, no blank rows, a real date in the Date column.</Step> |
| 135 | <Step title="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.</Step> |
| 136 | <Step title="Add rows">Drag or add Product to Rows.</Step> |
| 137 | <Step title="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".</Step> |
| 138 | <Step title="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.</Step> |
| 139 | <Step title="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.</Step> |
| 140 | </Steps> |
| 141 | |
| 142 | ### Keep it up to date |
| 143 | |
| 144 | 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. |
| 145 | |
| 146 | ## Getting AI help |
| 147 | |
| 148 | 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. |
| 149 | |
| 150 | ## Common mistakes |
| 151 | |
| 152 | - Using VLOOKUP for new work when XLOOKUP is available |
| 153 | - Forgetting to lock lookup ranges before filling down |
| 154 | - A pivot that counts instead of sums |
| 155 | - Dates stored as text, so they will not group by month |
| 156 | - Forgetting to refresh an Excel pivot after adding data when Auto Refresh is off or not available |