Short answer: LOOKUPVALUE ( result_column, search_column, search_value, ... [, alternate] ) returns the value of result_column in the row where every search column equals its search value, like a VLOOKUP with several keys. No match returns BLANK (or the alternate); several matching rows with different results return an error (or the alternate). If a relationship exists between the tables, Microsoft notes RELATED is usually more efficient. Use LOOKUPVALUE for lookups without a relationship: a rate valid on a date, a value by two keys.
People coming from Excel reach for LOOKUPVALUE for every lookup. In a model with relationships, most lookups are RELATED, and the rest are often better solved in Power Query.
What does it look like?
-- calculated column on Sales: the exchange rate for the order's currency and date
Rate =
LOOKUPVALUE (
Rates[Rate],
Rates[Currency], Sales[Currency],
Rates[Date], Sales[Order Date],
1
)
Amount EUR = Sales[Amount] * Sales[Rate]The last argument, 1, is the alternate result: rows with no rate get 1. Without it they would get BLANK.
How does it behave with matches?
| Matching rows | Result values | Returns |
|---|---|---|
| none | BLANK or alternate | |
| one | 0.92 | 0.92 |
| several | all 0.92 | 0.92 |
| several | 0.92 and 0.95 | error, or the alternate if given |
The error is "A table of multiple values was supplied where a single value was expected". It usually means the lookup table has duplicates; fix the data rather than hiding it with an alternate.
When is RELATED better?
-- with a relationship Sales[Product Key] to Product[Product Key]
Category = RELATED ( 'Product'[Category] )
-- the same without using the relationship, slower
Category Lookup = LOOKUPVALUE ( 'Product'[Category], 'Product'[Product Key], Sales[Product Key] )Relationships are indexed; LOOKUPVALUE searches. A relationship also filters in visuals, which a looked-up column does not.
What about "the price valid on that date"?
Price lists with valid-from dates have no exact date match. LOOKUPVALUE needs exact matches, so use the latest row on or before the date:
-- calculated column on Sales
Unit List Price =
VAR D = Sales[Order Date]
VAR P = Sales[Product Key]
RETURN
MAXX (
TOPN (
1,
FILTER ( Prices, Prices[Product Key] = P && Prices[Valid From] <= D ),
Prices[Valid From], DESC
),
Prices[Price]
)For large tables, do this join in Power Query or the source.
What goes wrong?
- Duplicates in the lookup table. The error appears only for keys with different results; check with
COUNTROWSper key. - Using it in measures over many rows. Each call searches; in an iterator over millions of rows this is slow.
- Types that differ. A text key against a number key never matches; align data types.
- Instead of a relationship. If the key is unique on one side, create the relationship and use
RELATED.
Where can you check this?
- Microsoft Learn: LOOKUPVALUE function (DAX)
- Microsoft Learn: RELATED function (DAX)
- Microsoft Learn: TOPN function (DAX)
Where do you start?
Replace each LOOKUPVALUE that follows an existing relationship with RELATED, and move date-range lookups to Power Query. Relationship functions covers RELATED and inactive relationships.