Practice problems / Lookup & Reference

Look up salary by employee ID (XLOOKUP)

Easy Lookup & Reference
Description
Hints 0/4
Solutions 3
–
Test case
1
2
3
Reset
Submit
fx
A
B
C
D
E
F
G
1
2
3
4
5
6
7
8
9
10
Loading interactive spreadsheet...
Preparing grid cells and formula calculation engine
○ Ready Enter formula in highlighted cells, then click Submit.

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)
The exercise data, as a table
ABCEFG
1 Employee IDNameSalaryLookup IDDeptMatched salary
2 E101Alex Zhang18500E104Engineering
3 E102Betty Lin22000E102Design
4 E103Chris Wu15000E101Operations
5 E104David Chen31000E103Sales
6 E105Emma Liu26000E105Marketing

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.

  1. Target cells are G2:G6 — start in G2, then fill down
  2. In G2, lookup_value is E2
  3. lookup_array is A2:A6 and return_array is C2:C6
  4. 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

Related practice

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.