The DAX LOOKUPVALUE function retrieves a value from a column in another table (or the same table) based on one or more search conditions. In its simplest form, use LOOKUPVALUE(Result_Column, Search_Column1, Search_Value1) to return the matching value from Result_Column where Search_Column1 equals Search_Value1. For example, LOOKUPVALUE(Products[ProductName], Products[ProductID], Sales[ProductID]) returns the product name for each sale.
What Is LOOKUPVALUE in DAX?
LOOKUPVALUE is a scalar function in DAX (Data Analysis Expressions), the formula language used in Power Pivot, Power BI, and Analysis Services. It works like a simplified VLOOKUP in Excel, but it is designed for column-based lookups in tabular data models. Unlike Excel’s VLOOKUP, LOOKUPVALUE does not require the lookup column to be the first column, and it can search across multiple tables without creating a relationship.
Key characteristics:
- Returns a single value (scalar), not a table.
- Uses exact match by default; no approximate match option.
- Can handle multiple search conditions (up to 14 pairs of search column and value).
- Requires that the search returns exactly one row; if multiple rows match, it returns an error unless you specify an alternate result.
How to Write a LOOKUPVALUE Formula
The syntax is:
LOOKUPVALUE(<Result_Column>, <Search_Column1>, <Search_Value1>[, <Search_Column2>, <Search_Value2>]…[, <Alternate_Result>])
Here is a concrete example. Assume you have two tables: Sales (with columns: SaleID, ProductID, Amount) and Products (with columns: ProductID, ProductName, Category). To add a calculated column in the Sales table that shows the product name, use:
Sales[ProductName] = LOOKUPVALUE(Products[ProductName], Products[ProductID], Sales[ProductID])
This looks up the ProductName in the Products table where ProductID matches the ProductID in the current row of Sales.
For multiple conditions, say you need to match on both ProductID and Region. The formula would be:
LOOKUPVALUE(Products[ProductName], Products[ProductID], Sales[ProductID], Products[Region], Sales[Region])
This returns the product name only when both the ProductID and Region match.
When to Use LOOKUPVALUE vs. RELATED
In Power BI and Power Pivot, the RELATED function is often a better choice when a relationship already exists between tables. RELATED returns a value from a related table on the “one” side of a one-to-many relationship. For example, if Sales has a many-to-one relationship with Products on ProductID, you can simply write RELATED(Products[ProductName]).
Use LOOKUPVALUE when:
- There is no relationship between the tables (or you want to avoid creating one).
- You need to match on multiple columns that are not part of a relationship.
- You want to perform a lookup in a table that is not related in the model.
However, LOOKUPVALUE is generally slower than RELATED because it does not leverage the in-memory relationship engine. For large datasets, prefer RELATED when possible.
Common Errors and How to Fix Them
LOOKUPVALUE returns an error in two common situations:
- Multiple matches: If the search criteria match more than one row in the lookup table, the function returns an error. To fix this, add an alternate result as the last argument. For example:
LOOKUPVALUE(Products[ProductName], Products[ProductID], Sales[ProductID], "Unknown")returns “Unknown” if there are multiple matches or no match. - No match: If no row matches, the function returns BLANK by default (unless you specify an alternate result). This is often acceptable, but if you need a specific value, use the alternate result.
Another common mistake is using a table name instead of a column name in the result column. Always use the fully qualified column name (Table[Column]).
Performance Considerations
LOOKUPVALUE can be slow on large tables because it performs a row-by-row search. To improve performance:
- Use relationships and RELATED whenever possible.
- Ensure the search columns are indexed (in the storage engine, columns are automatically indexed, but the lookup still scans).
- Limit the use of LOOKUPVALUE in calculated columns on large fact tables; consider doing the lookup in Power Query (M) instead.
- If you must use LOOKUPVALUE, try to reduce the number of rows in the lookup table by filtering or summarizing.
For very large models, consider using CALCULATE with FILTER or using CONCATENATEX for a different approach, but those are more complex.
Alternatives to LOOKUPVALUE
Besides RELATED, other DAX functions can achieve similar results:
- CALCULATE with FILTER:
CALCULATE(MAX(Products[ProductName]), FILTER(Products, Products[ProductID] = Sales[ProductID]))returns the product name, but it is verbose and slower. - USERELATIONSHIP: If you have inactive relationships, you can activate them temporarily with
CALCULATEandUSERELATIONSHIP, then use RELATED. - Power Query Merge: In Power Query Editor, you can merge queries to bring in columns from another table, which is often more efficient for data transformation.
- LOOKUPVALUE with alternate result: As shown, you can provide a fallback value to avoid errors.
For Excel users familiar with VLOOKUP, note that LOOKUPVALUE does not support approximate match or wildcards. It is strictly exact match.
Frequently Asked Questions
Can LOOKUPVALUE return multiple columns?
No, LOOKUPVALUE returns a single scalar value. To get multiple columns, you would need to write separate LOOKUPVALUE formulas for each column, or use a related table and RELATED.
What happens if LOOKUPVALUE finds multiple matches?
By default, it returns an error. You can avoid this by providing an alternate result as the last argument, which will be returned if there are multiple matches or no match. For example, LOOKUPVALUE(Products[ProductName], Products[ProductID], Sales[ProductID], "Multiple").
Can I use LOOKUPVALUE with a date range?
LOOKUPVALUE only does exact match on the search columns. To find a value based on a date range, you would need to use a different approach, such as CALCULATE with FILTER and date comparisons, or create a calculated column that flags the date range.
Is LOOKUPVALUE case-sensitive?
In DAX, text comparisons are case-insensitive by default. So LOOKUPVALUE(Products[ProductName], Products[Category], "electronics") will match “Electronics” as well. If you need case-sensitive lookup, you can use EXACT within a FILTER, but that is more complex.
Can I use LOOKUPVALUE in a measure?
Yes, you can use LOOKUPVALUE in a measure, but be careful with context. In a measure, the search values are evaluated in the current filter context. For example, Measure = LOOKUPVALUE(Products[ProductName], Products[ProductID], SELECTEDVALUE(Sales[ProductID])) returns the product name for the selected product ID.
What is the difference between LOOKUPVALUE and VLOOKUP in Excel?
VLOOKUP works on a single table range and returns a value from a specified column based on a lookup value. LOOKUPVALUE works across tables in a data model and can use multiple search columns. VLOOKUP supports approximate match and wildcards, while LOOKUPVALUE does not. Also, VLOOKUP requires the lookup column to be the first column in the range, but LOOKUPVALUE has no such restriction.
Related
- How to Update a Dictionary in Python
- Value Dollar Shop Jurong East: Location, Prices & What to Expect
- How to Select All on a Laptop: 5 Fast Ways
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Can You Make Columns in Word? A Quick GuideYes. In Microsoft Word for Microsoft 365 on Windows, select the text you want to format, then choose…
- How to Show Negative Numbers in Brackets in ExcelTo show negative numbers in brackets in Excel without changing their values, select the cells, press Ctrl+1, choose…
- PowerPoint Notes: How to See Them While PresentingTo see your speaker notes while presenting, turn on Presenter View in PowerPoint and show the presentation on…
- How to Divide a Cell in Half in Excel: 3 OptionsTo divide a cell in half in Excel, first choose what you mean by “divide”: Excel cannot turn…
- How to Open a Query in Excel and Edit It in Power QueryTo open an existing query in Excel for Microsoft 365 on Windows, go to Data > Queries &…
- Keep Only One Duplicate in Excel: Step-by-StepTo keep one copy of each repeated entry in Excel, select your data, choose Data > Remove Duplicates,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.