Excel & SQL for Analysis · Lesson 3 of 6
Excel for Data Analysis: Pivot Tables, XLOOKUP and Formulas That Matter
You do not need 400 Excel functions. You need about a dozen, used well. Learn tables, SUMIFS and COUNTIFS, XLOOKUP, pivot tables and conditional formatting with one realistic sales dataset.
Excel is still the most used analytics tool in the world. In many Indian companies, the first test in an analyst interview is a laptop, an Excel file and 30 minutes. The good news: a small set of features covers nearly everything you will be asked.
We will use one dataset throughout — a sheet of orders from an electronics store chain:
| OrderID | Date | City | Category | ProductID | Qty | Amount |
|---|---|---|---|---|---|---|
| 1001 | 02-10-2026 | Pune | Mobiles | P12 | 1 | 18,999 |
| 1002 | 02-10-2026 | Delhi | Laptops | P31 | 1 | 56,500 |
| 1003 | 03-10-2026 | Pune | Accessories | P07 | 3 | 2,397 |
1. Turn the range into a Table first
Click inside the data and press Ctrl + T. A Table gives you filters, banded rows, formulas that copy themselves down, and ranges that grow automatically when new rows arrive. Name it Orders (Table Design → Table Name). Now formulas can say Orders[Amount] instead of G2:G5000.
2. Conditional totals: SUMIFS and COUNTIFS
Total sales in Pune: =SUMIFS(Orders[Amount], Orders[City], "Pune")
Laptop sales in Pune: =SUMIFS(Orders[Amount], Orders[City], "Pune", Orders[Category], "Laptops")
Orders above ₹20,000: =COUNTIFS(Orders[Amount], ">20000")
Average order value in Delhi: =AVERAGEIFS(Orders[Amount], Orders[City], "Delhi")
The pattern is always: what to add up, then pairs of where to look, what to match. Put the city name in a cell (say J2) and use J2 instead of "Pune" so one formula works for every city.
3. Bringing data together: XLOOKUP
Product names and costs live on another sheet, Products. To bring the product name into each order:
=XLOOKUP([@ProductID], Products[ProductID], Products[Name], "Not found")
Read it as: look for this order's ProductID in the Products ID column, return the Name from the same row, and say "Not found" if it is missing. XLOOKUP replaces VLOOKUP: it can look left, does not break when columns are inserted, and handles missing values cleanly. If your company still uses older Excel, learn INDEX + MATCH as the fallback.
Classic interview trap: VLOOKUP's last argument. Leaving it out means "approximate match", which silently returns wrong rows on unsorted data. Always use FALSE (exact match) — or just use XLOOKUP, which is exact by default.
4. Pivot tables: the analyst's favourite tool
Insert → PivotTable → select the Orders table. Then drag fields:
- Rows: City · Columns: Category · Values: Sum of Amount
In ten seconds you have sales by city and category — a summary that would take dozens of formulas. A few moves every analyst uses:
- Group dates by month or quarter (right-click a date → Group).
- Show values as % of grand total or % of row total to compare share, not just size.
- Add a slicer (PivotTable Analyze → Insert Slicer) for one-click filters by city or month.
- Change "Sum" to "Count" or "Average" in Value Field Settings — count of orders and average order value tell different stories.
- Refresh after new data arrives (right-click → Refresh). Because the source is a Table, new rows are included automatically.
5. Conditional formatting: make problems visible
Select a column and use Home → Conditional Formatting: colour scales for sales by city, data bars for quantities, or a rule like "Amount less than 0" in red to catch data errors. Use it to guide the eye to one thing — a sheet where every cell is coloured guides it nowhere.
6. A few more functions worth knowing
IFandIFS— categorise:=IF([@Amount]>=20000, "High value", "Regular")TEXT— extract a month name from a date:=TEXT([@Date], "mmm-yy")UNIQUE,SORTandFILTER— dynamic lists:=SORT(UNIQUE(Orders[City]))IFERROR— replace errors with something readable.
Remember: formulas for calculations that must update, pivot tables for exploring and summarising, charts for the final message. Knowing which to reach for is the real Excel skill.
Try it yourself: Build a 40-row orders sheet (or download a sample sales dataset). Answer: (1) top city by sales, (2) each category's share of total sales, (3) the month with the most orders, (4) the average order value per city. Use a pivot table for 1–3 and AVERAGEIFS for 4, then check that both methods agree.
Common interview questions
Try answering each one aloud before you open it.
1What is the difference between VLOOKUP and XLOOKUP?
XLOOKUP can look in any direction, returns exact matches by default, does not break when columns are inserted and has a built-in "if not found" value. VLOOKUP only looks to the right, uses a column number and defaults to approximate match.
2What is a pivot table used for?
To summarise large data quickly — totals, counts, averages and percentages grouped by categories like city, product or month — and to explore it by dragging fields, filtering and drilling down without writing formulas.
3How would you calculate total sales for one city and one category?
With SUMIFS: =SUMIFS(Amount range, City range, "Pune", Category range, "Laptops"), ideally referencing cells for the criteria so the formula is reusable.
Practise this
Build something with it
FAQs
Is Excel enough for a data analyst job?
It gets you started and is used everywhere, but most roles also expect SQL and a dashboard tool. Python helps for larger data and automation.
Google Sheets or Excel?
The core ideas — SUMIFS, lookups, pivot tables — work in both. Excel is more common in corporate interviews; Sheets is great for practice and collaboration.
References & further reading
Finished this lesson?
Mark it complete. Create a free account to save it on every device.