Expires in:
In this article you will learn how to build an interactive Excel scorecard using XLOOKUP, dynamic arrays, and structured table references. I walk through real examples using World Bank 2018 data so you can follow step by step. This is practical guidance for analysts, dashboard builders, and anyone who wants to replace legacy lookup formulas with modern, flexible XLOOKUP logic.

Key Take-Aways
- XLOOKUP replaces VLOOKUP and INDEX/MATCH for most lookup needs and can search left or right.
- Structured table references make formulas clearer and more resilient than A1 ranges.
- Dynamic arrays let a single XLOOKUP spill results across columns or rows, returning multiple values with one formula.
- Use the optional if_not_found, match_mode, and search_mode arguments to handle missing values, wildcards, and approximate matches.
- You can nest XLOOKUPs to choose return columns dynamically, enabling user-driven dashboards.
## Why this approach matters
We are building a completely dynamic scorecard from World Bank 2018 data. The goal is to retrieve multiple fields for a selected country, categorize numeric values using approximate matching, and surface lists of similar countries using dynamic arrays. These techniques reduce formula repetition, improve maintainability, and let users interact with the dashboard without breaking formulas.
## The dataset and table setup
- Import your source into an Excel table and name it. In the example I named the table `countries`.
- A table converts ranges into structured references like `countries[Country]` and keeps formulas readable and stable when rows are added or removed.
- Typical columns in the sample set: Country Code, Country Name, Region, Life Expectancy, Population, Unemployment, GDP (millions).
Why use a table
- Shorter formulas and explicit column names.
- Tables expand automatically when new data is added.
- Structured references work everywhere that A1 references work, but are easier to interpret.
## Basic XLOOKUP syntax and first examples
XLOOKUP replaces older lookups. The simplified signature is:
`XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])`
- `lookup_value` is the value you want to find.
- `lookup_array` is the column to search.
- `return_array` is the column to return a value from.
Example 1: Return the selected country name
`=XLOOKUP($S$2, countries[Country], countries[Country])`
Example 2: Return the region for the selected country
`=XLOOKUP($S$2, countries[Country], countries[Region])`
Example 3: Return a country code that sits left of the lookup column
VLOOKUP cannot look left. XLOOKUP can. If the code lives to the left of the country name:
`=XLOOKUP($S$2, countries[Country], countries[Code])`
This returns values like JPN when the selected country is Japan.
## Dynamic arrays: return multiple fields with one formula
Instead of writing a formula for Life Expectancy, another for Population, and another for Unemployment, select the full return range in the table and let XLOOKUP spill.
Example returning three columns at once
`=XLOOKUP($S$2, countries[Country], countries[Life Expectancy]:countries[Unemployment])`
When entered, this single formula spills across three columns and populates all metrics for the selected country. The formula itself lives in the top-left cell of the spill range, and Excel handles the rest.
## Handling missing matches and wildcards
- if_not_found argument avoids #N/A when a user types a value that is not present. For text, you might return a dash or friendly message.
`=XLOOKUP($S$2, countries[Country], countries[Country], "-")`
- For fuzzy text entry use wildcard match mode. Set `match_mode` to 2 (wildcard character match). Use `*` for any number of characters, `?` for a single character.
`=XLOOKUP("KAZ*", countries[Country], countries[Country], "-", 2)`
This will match Kazakhstan when the user types KAZ or KAZ*.
## Approximate matching for numeric categories
When categorizing numeric values against thresholds, use XLOOKUP with `match_mode` set to -1 or 1. For example, define a separate small table `GDP_category` with thresholds and labels.
`=XLOOKUP([@GDP], GDP_category[Threshold], GDP_category[Category], "-", -1)`
- Use `-1` to return an exact match or the next smaller item. This lets you map continuous GDP numbers to discrete buckets. Excel scans until it finds the first higher value and uses the previous threshold as the match.
## Nesting XLOOKUPs for dynamic return arrays
To let users choose which metric to display in a similar-countries list, nest an XLOOKUP inside the return_array argument. The outer XLOOKUP looks up an index, and the inner XLOOKUP resolves which column to return based on the selected header.
Outline:
1. Outer XLOOKUP uses index values that rank countries by GDP or another metric.
2. Inner XLOOKUP finds the header selected by the user from the table headers.
3. The inner XLOOKUP returns a column reference which becomes the return array for the outer XLOOKUP.
Example concept
`=XLOOKUP(L11:L21, countries[Index], XLOOKUP($N$10, TableHeaders, countries[#All]))`
This returns a dynamic column chosen by the user via dropdown. The spilled results fill rows for similar countries.
## Practical shortcuts and visualization
- To copy a formula but not its formatting, use Copy then Alt H V F (Paste as Formula). This keeps currency or number formats from propagating unintentionally.
- After populating data, insert a Filled Map chart to visualize country-level metrics. The map updates dynamically as the lookup selection changes.
## Additional Tips, Pitfalls to Avoid & Pro Advice
- Always lock lookup_value references with F4 when needed so copied formulas reference the intended cell.
- When using structured references inside dynamic arrays, be careful to reference the full column or the correct portion of the table.
- Use `if_not_found` to give users friendly feedback instead of #N/A. This makes dashboards feel stable.
- Wildcards are great for partial names but can introduce false matches if your dataset has many similar entries. Consider data validation lists for exact user input when possible.
- For approximate matches, ensure your threshold table is sorted ascending to avoid incorrect buckets.
## Frequently Asked Questions
Q: Can XLOOKUP search to the left of the lookup column
A: Yes. XLOOKUP can return values to the left or right of the lookup column. Just provide the lookup_array and return_array in any order you need.
Q: How do I return multiple columns with one XLOOKUP
A: Point the return_array at a contiguous range of columns in a table or worksheet. XLOOKUP will spill results across those columns automatically using dynamic arrays.
Q: What does match_mode = 2 do in XLOOKUP
A: match_mode = 2 enables wildcard character match. Use `*` for any number of characters and `?` for a single character. This is useful for partial text matches.
Q: How do I map numeric values into categories with XLOOKUP
A: Create a small threshold table with lower bounds and labels, then use XLOOKUP with match_mode = -1 for exact or next smaller item. Ensure the threshold column is sorted ascending.
Q: Can I use XLOOKUP across different workbooks
A: Yes. XLOOKUP can reference ranges in other open workbooks, but references become static if the source workbook is closed. Prefer keeping data in the same workbook for dashboards.
## Summary of Key Points / Take-Home Messages
- Use tables to make lookups readable and robust.
- XLOOKUP handles left and right lookups, wildcards, and approximate matches.
- Dynamic arrays let one formula return multiple values across columns or rows.
- Nest XLOOKUP functions to make return columns dynamic and user-driven.
- Add if_not_found to improve the user experience and avoid #N/A errors.
With these patterns you can replace legacy lookup formulas, build interactive dashboards, and write cleaner, more maintainable Excel logic.






