Look up salary by employee ID (XLOOKUP)
The problem
Problem statement
You are putting together a department salary report. Employee IDs and departments are already filled in, but the Matched salary column is still empty. Write a formula in G2:G6 so each row looks up the salary for the employee ID in column E from the staff roster in A2:C6.
The same formula is filled down G2:G6 — lock the lookup and return arrays with $ instead of retyping them per row.
Problem data
Show the sheet as a table (selectable, copyable)
| A | B | C | E | F | G | |
|---|---|---|---|---|---|---|
| 1 | Employee ID | Name | Salary | Lookup ID | Dept | Matched salary |
| 2 | E101 | Alex Zhang | 18500 | E104 | Engineering | |
| 3 | E102 | Betty Lin | 22000 | E102 | Design | |
| 4 | E103 | Chris Wu | 15000 | E101 | Operations | |
| 5 | E104 | David Chen | 31000 | E103 | Sales | |
| 6 | E105 | Emma Liu | 26000 | E105 | Marketing |
Notes
XLOOKUP does not require a column index. Keep lookup and return arrays the same height. Default match mode is exact. Lock the table ranges with $ if you fill the formula down.
How to approach
Your answer goes in G2:G6. On submit we re-run your formula against 3 different sets of input, so a hardcoded number will fail — the formula has to follow the cells.
- Target cells are G2:G6 — start in G2, then fill down
- In G2, lookup_value is E2
- lookup_array is A2:A6 and return_array is C2:C6
- Lock A2:A6 and C2:C6 with $ before filling down so the source table stays fixed
Official solutions
Show 3 solutions — try it yourself first
Approach 1: Standard XLOOKUP exact match
=XLOOKUP(E2, A2:A6, C2:C6)
XLOOKUP searches the ID column in A2:A6 for the key in E2, then retrieves the matching salary from C2:C6. Exact match is the default. Enter this in G2 first.
Approach 2: XLOOKUP with locked ranges ($)
=XLOOKUP(E2, $A$2:$A$6, $C$2:$C$6)
Locking the lookup and return arrays ($) keeps the source table fixed when you fill G2 down through G6. Relative E2 becomes E3, E4, … so each row looks up its own ID.
Approach 3: INDEX + MATCH (classic equivalent)
=INDEX(C2:C6, MATCH(E2, A2:A6, 0))
MATCH finds the row of E2 inside A2:A6 (0 = exact). INDEX then returns the same-row salary from C2:C6. This exercise still grades XLOOKUP, but INDEX/MATCH is the pre-XLOOKUP pattern interviewers often ask about.
Function guide
FAQ
How do I look up a salary with XLOOKUP?
Use =XLOOKUP(E2, A2:A6, C2:C6) when E2 holds the ID, A2:A6 the ID list, and C2:C6 the salaries. Fill down for the other Lookup ID rows.
Does XLOOKUP need a column index like VLOOKUP?
No. You pass the return array directly, so column moves will not break a column-index argument.
Why lock ranges with $ when filling down?
Without $, A2:A6 and C2:C6 shift as you copy the formula down. Absolute refs $A$2:$A$6 and $C$2:$C$6 keep the employee table fixed while E2 becomes E3, E4, and so on.