LOOKUPVALUE DAX Function in Power BI – A Complete Guide
If you want to extract specific values from a table in Power BI, the LOOKUPVALUE DAX function is the way to go. But what’s the secret behind its syntax and parameters, and how can you use it properly? We’re about to find out in this guide.
For instance, we’ll dive deep into the LOOKUPVALUE function, its applications, syntax, and best practices in this guide. This will help you get the knowledge and skills you need to make the most out of this remarkable Power BI function.
With that said, let’s roll in.
LOOKUPVALUE in Power BI: Quick Overview
In Power BI, LOOKUPVALUE is a DAX function used to retrieve a value from a table. This function is similar to VLOOKUP in MS Excel.
One important feature of Power BI’s LOOKUPVALUE function is its ability to manage multiple search conditions. It lets you define multiple criteria for extracting the desired data from a table. For instance, you can use both the product and region as search conditions to retrieve the sales amount for a specific product and region.
We’ll explore its syntax and examples in detail later in this guide.
Use Cases of LOOKUPVALUE for Professionals
The LOOKUPVALUE function in Power BI greatly helps with data analysis, reporting, data modeling, and custom calculations. It improves data analysis by swiftly matching and retrieving related information from diverse tables. It’s also helpful in reporting as it consolidates data from multiple sources to create more informative and detailed reports.
Also, since it simplifies building relationships between tables, it’s quite useful in data modeling, too. Apart from that, the LOOPUPVALUE function is remarkable for custom calculations. It lets you create tailored, data-driven metrics for calculations.
That said, since LOOKUPVALUE improves data retrieval, it’s useful for various decision-making professionals in sales, marketing, finance, and HR.
If you’re a sales professional, use it to find specific product sales figures easily. Marketers benefit by matching campaign data with customer profiles. Financial analysts access critical data, like stock prices, for specific dates. Also, HR professionals can merge employee details across databases.
How to Use Power BI’s LOOKUPVALUE Function
Here, we’ll explore the steps to use the LOOKUPVALUE function, starting with its syntax and parameters.
To use the LOOKUPVALUE function, you’ll need first to know its syntax. Here it is:
[, <search2_columnName>, <search2_value>]…
The parameters of a function are input values it receives. They define how a function operates and allow customization for different tasks. When it comes to LOOKUPVALUE, knowing its parameters is important to use it properly.
To explore LOOKUPVALUE’s parameter, imagine you have three tables: “Product_Table,” “Tax_Table,” and “Discount_Table.” While the last two tables have “Tax %” and “Discount %” data, the “Product_Table” lacks this info. The common column among them is “Product.”
In this case, the parameters you can use include:
- Result Column Name: This specifies which column you want results from in other tables. For instance, you want data from the “Tax %” column in “Tax_Table” and the “Discount %” column in “Discount_Table.”
- Search Column Name: This indicates the column in the target table (Tax_Table or Discount_Table) you use to search for data.
- Search Value: This column comes from the table where you’re applying LOOKUPVALUE. It should match the “Search Column Name” in other tables. In this case, the “Product_Table” and the “Product” column are the same.
Apart from that, there’s another parameter called Alternate Result (alternateResult), though it’s optional. This parameter determines what the function should do when it can’t find an exact match or when there are multiple matches.
You can set it to return a specific value instead of a blank or an error. This way, it gives you more control over the function’s behavior.
Steps For Using LOOKUPVALUE
Follow these steps to retrieve data from one table and add it to another using LOOKUPVALUE in Power BI:
Step 1: Import Data Tables
To begin, let’s imagine we have two tables: “Sales” and “Products.” The “Sales” table contains information about products sold, including their names, prices, and quantities. The “Products” table includes product details, such as their names and categories.
Step 2: Add a New Column
We want to add a new column in the “Sales” table to retrieve the product category from the “Products” table. Right-click on the “Sales” table, and select “New column.”
Step 3: Name the New Column
Give the new column a name; for example, “Product Category.”
Step 4: Use LOOKUPVALUE
Now, let’s use the LOOKUPVALUE function. In this case:
The first argument, “Result Column Name,” should be the column you want to fetch from the “Products” table, which is “Category.”
The second argument, “Search Column Name 1,” is the column you’re matching in the “Products” table, which is “Product Name.”
Lastly, the third argument, “Search Value,” should be the column from the “Sales” table that matches the “Product Name.”
Step 5: Calculate the Result
Now, close the bracket and press “Enter.” The new “Product Category” column will now display the product category for each product in the “Sales” table, retrieved from the “Products” table.
Step 6: Adjust Format (Optional)
If needed, you can adjust the format of the “Product Category” column by going to the “Modeling” tab.
Step 7: Handling No Matches
Remember that sometimes the LOOKUPVALUE function can’t find a match for a specific product name in the “Products” table. In such a case, the “Product Category” column in the “Sales” table will display a blank value.
Step 8: Extending to More Columns
You can repeat these steps to retrieve other information from the “Products” table into the “Sales” table. For instance, you can create new columns to fetch the product price or any other relevant data. Each time, you’d specify the appropriate “Result Column Name,” “Search Column Name 1,” and “Search Value” to match your specific needs.
Example of Using LOOKUPVALUE Function
Here, we’ll explore an example of using the LOOKUPVALUE function to get our desired result:
In a Power BI dataset, you have two tables: “Sales” and “Products.” The “Sales” table has information about products sold, like the product name, quantity, and sales amount. The “Products” table includes product details, including their names and categories.
You want to add a new column to the “Sales” table called “Product Category.” This new column will use the LOOKUPVALUE function to retrieve the product category from the “Products” table based on the product name.
After applying the LOOKUPVALUE function, the “Product Category” column in the “Sales” table will display the product categories for each product. This simplifies reporting and analysis and makes it easier to understand and work with your sales data.
Things to Know Before Using LOOKUPVALUE
Before using LOOKUPVALUE in Power BI, there are a few things you should remember:
- Blank Result: Remember that LOOKUPVALUE is a lookupvalue function, and if no match is found, it returns a blank result.
- Don’t Specify Parameters: Many users confuse LOOKUPVALUE with VLOOKUP. Unlike the latter, the LOOKUPVALUE function doesn’t require specifying column names or range lookup parameters.
- Matching Result Column and Search Value Column: When using LOOKUPVALUE, ensure that the Result Column and Search Value columns match in both tables. Otherwise, it might be unable to retrieve your desired value.
- Not Supported in DirectQuery Mode: In DirectQuery mode, you can’t use this function in calculated columns or row-level security rules; it’s unsupported in these contexts.
- RELATED vs. LOOKUPVALUE: For better performance and efficiency, when a relationship exists between the result and search tables, it’s worth using the RELATED function instead of LOOKUPVALUE.
Conclusion / EPC Group Expertise in Power BI Services
In this guide, we explored that LOOKUPVALUE in Power BI is an important tool for fetching data from tables. It’s similar to a search engine that finds information based on a shared column.
Since LOOKUPVALUE simplifies data retrieval, it’s invaluable for various professions, especially ones involving data. If you’re looking to retrieve values from tables, start experimenting with this function right away. That said, if you want reliable Power BI support and consultation, consider consulting with professionals like EPC Group, a Microsoft Gold Partner. Our award-winning IT consulting services provide expert solutions and guidance to provide you with a competitive edge through data-driven insights!
With over 25 years of experience in Information Technology and Management Consulting, Errin O’Connor has led hundreds of large-scale enterprise implementations from Business Intelligence, Power BI, Office 365, SharePoint, Exchange, IT Security, Azure and Hybrid Cloud eﬀorts for over 165 Fortune 500 companies.