Function Problems

How to Add a Department to an Excel Report Using XLOOKUP

Steve KSteve K Nov 10, 2026 868 views

Question details

The user needs to retrieve department names from a master workbook and add them to an extracted report by matching Employee IDs.

How to Add a Department to an Excel Report Using XLOOKUP
Product
Excel / WPS Spreadsheet
Device & OS
not provided
Scenario
Merging data from two separate workbooks (a master staff list and an hours logged report) based on a common identifier.
Observed behavior
The extracted report lacks department information, requiring a lookup function or query tool to automatically pull the correct department for each employee.
Before you start

Ensure both your master workbook and the extracted report are open in your spreadsheet software to make selecting your data ranges easier and to prevent broken link errors.

Solution 1Recommended

Use the XLOOKUP Function to Match Data

XLOOKUP is the most efficient and modern way to retrieve data from another sheet or workbook based on a matching identifier.

The XLOOKUP function allows you to search for an Employee ID in the master workbook and return the corresponding Department name to your current report. It replaces older functions like VLOOKUP and provides built-in error handling.

1
Open your files and select the target cell

Open both the master workbook and your extracted report. In the extracted report, click on the first empty cell in your new 'Department' column (for example, C2).

2
Start the XLOOKUP formula

Type `=XLOOKUP(B2,` into the cell, where B2 is the cell containing the Employee ID in your current report.

3
Set the lookup array

Switch to your master workbook window, click the column header for the Employee ID (e.g., Column B) to select the entire column, and type a comma. The formula will look similar to `=XLOOKUP(B2,[Master.xlsx]Sheet1!$B:$B,`.

4
Set the return array

Still in the master workbook, click the column header for the Department (e.g., Column C) to select it.

5
Add error handling and finish

Type a comma, add the text `"Not found"` to handle any IDs that do not exist in the master sheet, close the parentheses, and press Enter. The final formula will look like `=XLOOKUP(B2,[Master.xlsx]Sheet1!$B:$B,[Master.xlsx]Sheet1!$C:$C,"Not found")`.

6
Apply to all rows

Click the cell with the completed formula and double-click the small square (fill handle) in the bottom-right corner to copy the formula down to the rest of the rows in your report.

Use the XLOOKUP Function to Match Data
Pro Tip: Once the XLOOKUP formula successfully populates the departments, it is best practice to highlight the column, copy it, and use 'Paste Special > Values' over the same cells. This removes the formula dependency, allowing you to close the master workbook without breaking the data.
Advanced Spreadsheet Functions

Match and Merge Data Effortlessly with WPS Spreadsheet

WPS Spreadsheet fully supports advanced functions like XLOOKUP, VLOOKUP, and dynamic arrays, making it incredibly easy to merge data from multiple reports. It offers a fast, lightweight, and highly compatible workspace for handling complex data sets.

  1. 1. Open your data sets: Launch WPS Spreadsheet and open both the master staff list and the exported hours report.
  2. 2. Insert the XLOOKUP formula: Navigate to the Formulas tab, click 'Insert Function', search for XLOOKUP, or directly type `=XLOOKUP(` into your target cell.
  3. 3. Define your matching criteria: Follow the tooltip prompts to select the lookup value (Employee ID in the report), lookup array (Employee IDs in the master), and return array (Departments in the master).
  4. 4. Analyze the completed report: Drag the formula down to populate all rows. You can now use WPS Spreadsheet's PivotTable feature to summarize logged hours by each department.
Full support for XLOOKUP, ensuring seamless calculation and exact matching.100% compatibility with Microsoft Excel (.xlsx) formats and existing formulas.Lightweight and fast, opening large data reports in seconds.Free to download and use with a highly intuitive, tabbed user interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my XLOOKUP formula returning a #N/A error?

The #N/A error indicates that the specific Employee ID from your report cannot be found in the master workbook's ID column. This can happen if the ID is missing, or if there are formatting mismatches (e.g., one is formatted as text and the other as a number) or hidden trailing spaces.

Can I use VLOOKUP instead of XLOOKUP to find the department?

Yes, you can use VLOOKUP, provided that the Employee ID column is located to the left of the Department column in the master workbook. However, XLOOKUP is generally preferred because it does not require counting column index numbers, defaults to an exact match, and works regardless of column order.

How do I fix the #REF! error when I close my master workbook?

Sometimes cross-workbook formulas can break or slow down processing when the source file is closed. To prevent this, select your populated Department column, press Ctrl+C to copy, right-click the same selection, and choose 'Paste Special > Values'. This converts the formulas into static text so they no longer rely on the master workbook.