Excel / SQL lookup · Original fictional case · Free files and answers
XLOOKUP practice: preserve missing customers
The dispatch queue must keep every shipment even when the customer master is incomplete. Create an explicit review label rather than hiding an unmatched shipment.
Suggested time: 15–25 minutes. All records, companies, rates and work policies are invented for this exercise.
Your output contract
- Customer IDs are unique in this case and must match exactly.
- Every shipment must remain, including the zero-unit shipment. Missing keys receive REVIEW, not a blank or zero.
- Output shipment_id, region, units in shipment_id order.
Required columns: shipment_id, region, units. Row order is part of the contract. Empty output CSV fields represent NULL; zero remains 0.
Original source tables
shipments
5 source rows · Download shipments CSV
| shipment_id TEXT | customer_id TEXT | units INTEGER |
|---|---|---|
| S01 | C1 | 4 |
| S02 | C9 | 2 |
| S03 | C2 | 0 |
| S04 | C3 | 7 |
| S05 | C8 | 1 |
customers
3 source rows · Download customers CSV
| customer_id TEXT | region TEXT |
|---|---|
| C1 | North |
| C2 | West |
| C3 | East |
Plan the transformation
- Count the five source shipments before a lookup.
- In Excel import each CSV to its own sheet and use an exact lookup with an explicit missing label.
- In SQL preserve the shipment side with LEFT JOIN and compare row count and unit total.
Watch for this mistake
An inner join loses S02 and S05 and makes an incomplete dispatch queue look valid.
Work in Excel
With shipments on sheet Shipments and customers on Customers, put =XLOOKUP(B2,Customers!$A$2:$A$4,Customers!$B$2:$B$4,"REVIEW",0) in a new region column and fill down. Export only shipment_id,region,units in that order.
Use a version that supports XLOOKUP, such as Microsoft 365, Excel 2021 or Excel 2024. XLOOKUP is unavailable in Excel 2016 and 2019. The browser editor below executes SQLite; check an Excel result by uploading your final CSV.
Microsoft XLOOKUP syntax and compatibility
Run and check your SQLite result
The database runs locally in a worker. Use one SELECT or WITH query. Your query is saved on this device when storage is available. Download your SQL before clearing browser data.
Or work in Excel or another spreadsheet, then upload the final CSV with exactly the required columns.
Worked SQL and complete expected output
Five shipments and 14 units remain. Two shipment keys need master-data review.
SELECT s.shipment_id,COALESCE(c.region,'REVIEW') region,s.units FROM shipments s LEFT JOIN customers c ON c.customer_id=s.customer_id ORDER BY s.shipment_id;
| shipment_id | region | units |
|---|---|---|
| S01 | North | 4 |
| S02 | REVIEW | 2 |
| S03 | West | 0 |
| S04 | East | 7 |
| S05 | REVIEW | 1 |
Download reference SQL · Download complete expected CSV · Download an empty answer CSV · Download SQLite setup
What to pass to a colleague
Keep the checked output and SQL or spreadsheet result. Explain the exception policy, the cross-check above and any held records. The checker confirms this fixed case’s output; it does not evaluate arbitrary private business data.
SQLite SELECT, joins and aggregation reference · Continue with the larger workplace projects