In Power BI, you can look up values from another dataset (table) into a new column using the LOOKUPVALUE function in DAX (Data Analysis Expressions). This is useful when you want to bring over a specific value from a related table, especially when there's no active relationship or you need more control.
✅ Syntax of LOOKUPVALUE:
LOOKUPVALUE (
<result_column>, -- The column you want to retrieve
<search_column>, -- The column to search in the related table
<search_value>, -- The value to match in the search column
[<search_column2>, -- Optional additional columns for matching
<search_value2>,
...]
)
📌 Example Scenario
You have two tables:
-
Sales table:
-
Products table:
ProductID
ProductName
Price
You want to add a new column in the Sales table that shows the ProductName from the Products table based on matching ProductID.
💡 Solution: Create a Calculated Column Using DAX
- Go to the Modeling tab.
- Click New Column.
- Enter this formula:
ProductName =
LOOKUPVALUE (
Products[ProductName], -- What to return
Products[ProductID], -- Column to search in
Sales[ProductID] -- Value to match
)
This will create a new column in the Sales table with the corresponding product name from the Products table.
⚠️ Notes:
LOOKUPVALUE returns a single value. If multiple matches are found, it will return an error.
- Ensure that the relationship between tables is either one-to-one or one-to-many for predictable results.
- If a relationship already exists between the tables, consider using the
RELATED() function instead if you're fetching from the "one" side of the relationship.
✅ Alternative: Use RELATED() if Relationship Exists
If there's an active relationship between Sales[ProductID] and Products[ProductID], you can simply use:
ProductName = RELATED(Products[ProductName])
This is often faster and cleaner than LOOKUPVALUE.
Let me know if you want to do this in Power Query (M) instead!