Thủ Thuật
  • TOP Thủ Thuật
    • Thủ Thuật Internet
    • Thủ Thuật Máy Tính
    • Thủ Thuật Tiện Ích
    • Thủ Thuật Phần Mềm
  • Chia Sẻ Kiến Thức
    • Học Excel
    • Học Word
    • Học Power Point
  • Games
  • Kênh Công Nghệ
  • Facebook
  • WordPress
  • SEO
No Result
View All Result
Thủ Thuật
  • TOP Thủ Thuật
    • Thủ Thuật Internet
    • Thủ Thuật Máy Tính
    • Thủ Thuật Tiện Ích
    • Thủ Thuật Phần Mềm
  • Chia Sẻ Kiến Thức
    • Học Excel
    • Học Word
    • Học Power Point
  • Games
  • Kênh Công Nghệ
  • Facebook
  • WordPress
  • SEO
No Result
View All Result
Thủ Thuật
No Result
View All Result
Home Chia Sẻ Kiến Thức Học Excel

How to Perform Lookups via an Intermediate Table in Power BI Using DAX

How to Perform Lookups via an Intermediate Table in Power BI Using DAX
6k
SHARES
19.5k
VIEWS
Share on Facebook

Nội Dung Bài Viết

Toggle
  • Understanding the Data Scenario
    • 1. The List Table (DanhSach)
    • 2. The Sales Table (BanHang)
    • 3. The Intermediate Table (MaChiNhanh)
  • Analyzing the Relationships
  • The Solution: Combining RELATED and LOOKUPVALUE
    • The Logic Breakdown
    • The DAX Formula
  • Result and Validation
  • Conclusion
  • References

In the realm of Power BI data modeling, the RELATED and LOOKUPVALUE functions are fundamental tools for retrieving information across tables. Under standard circumstances, these functions operate seamlessly when there is a direct relationship between the table containing the search value and the table containing the desired result. However, real-world data scenarios are rarely that simple.

A common challenge arises when the relationship between two tables is not direct but is instead bridged by an intermediate table (often referred to as a bridge table or a snowflake schema scenario). When you need to pull data from Table A to Table C, but they are only connected through Table B, standard single-function logic fails.

This article explores the technical solution for this specific modeling problem, demonstrating how to nest RELATED within LOOKUPVALUE to traverse intermediate tables effectively.

Understanding the Data Scenario

To master this technique, we must first analyze the structure of the data. In complex data models, direct “One-to-Many” relationships are not always available for every lookup requirement.

Consider a scenario where we have three distinct tables. We need to fetch an Address for a transaction, but the transaction table does not contain the necessary ID code to look up the address directly.

1. The List Table (DanhSach)

This is our master data table containing the target information. It holds the Branch Code (Mã) and the Address (Địa chỉ). In a standard lookup, this would be our target table.

Screenshot of the List table in Power BI containing branch codes and addressesScreenshot of the List table in Power BI containing branch codes and addresses

2. The Sales Table (BanHang)

This is our fact table (transactional data). It contains the Branch Name (Tên) but, crucially, it lacks the Branch Code. Without the Branch Code, we cannot directly link it to the List Table described above.

Xem thêm:  Mastering Excel Conditional Statistics: A Guide to AVERAGEIFS, MAXIFS, and MINIFS

Screenshot of the Sales table showing branch names without codesScreenshot of the Sales table showing branch names without codes

3. The Intermediate Table (MaChiNhanh)

This table acts as the bridge. It contains both the Branch Name and the Branch Code (Mã CN). It defines the relationship between the names found in the Sales table and the codes found in the List table.

Screenshot of the intermediate Branch Code table linking names to codesScreenshot of the intermediate Branch Code table linking names to codes

Analyzing the Relationships

In Power BI’s model view, the relationship structure is critical. We are dealing with a chain where the Sales table connects to the Intermediate table, which in turn connects to the List table.

This structure implies that while there is a path from Sales to List, it is not a single hop. The RELATED function works based on row context propagation across an existing direct relationship (Many-to-One). Since there is no direct line from Sales to List, RELATED cannot be used alone. Similarly, LOOKUPVALUE requires a common search column, which does not exist directly between Sales (Names) and List (Codes).

Power BI data model diagram showing the relationship between Sales, Branch Code, and List tablesPower BI data model diagram showing the relationship between Sales, Branch Code, and List tables

The Objective: Create a calculated column named “Address” (Địa chỉ) in the Sales table (Table 2) by retrieving data from the List table (Table 1).

The Solution: Combining RELATED and LOOKUPVALUE

To bridge this gap, we must combine the strengths of both DAX functions. We will use LOOKUPVALUE to perform the search in the distant table, and RELATED to provide the search key from the intermediate table.

The Logic Breakdown

  1. LOOKUPVALUE acts as the primary vehicle. It allows us to search the DanhSach (List) table independent of the active relationship filtering direction. It requires a search column and a search value.
  2. The Constraint: The BanHang (Sales) table does not have the Code required to search the DanhSach table.
  3. The Fix: We use RELATED to grab the Code from the MaChiNhanh (Intermediate) table. Since BanHang is directly related to MaChiNhanh, RELATED can successfully fetch the code associated with the branch name in the current row context.
Xem thêm:  Tách Họ và Tên Đệm trong Excel Không Cần Công Thức

The DAX Formula

We will create a New Column in the BanHang table with the following syntax:

Dia chi = LOOKUPVALUE(
    DanhSach[Địa chỉ],        // The Result Column: What we want (Address)
    DanhSach[Mã],             // The Search Column: Where to look for the match
    RELATED( MaChiNhanh[Mã CN] ) // The Search Value: The key retrieved from the bridge table
)

Technical Explanation:

  • DanhSach[Địa chỉ]: This is the column we want to return.
  • DanhSach[Mã]: This is the column in the target table that contains the unique identifiers.
  • RELATED( MaChiNhanh[Mã CN] ): This function executes first. For every row in the Sales table, it looks at the connected Intermediate table and returns the corresponding Mã CN (Branch Code). This code is then passed to LOOKUPVALUE to find the matching address in the List table.

Result and Validation

After entering the formula, Power BI calculates the column row by row. It successfully “hops” over the intermediate table to retrieve the correct address.

This method ensures data integrity and avoids the need to physically merge tables using Power Query, which can unnecessarily bloat the data model and reduce performance with large datasets. Keeping the tables normalized and using DAX for retrieval is often the more efficient approach for reporting.

Power BI data view showing the calculated column with successfully retrieved addressesPower BI data view showing the calculated column with successfully retrieved addresses

Conclusion

Mastering lookup functions in Power BI distinguishes a novice user from a data modeling expert. While RELATED and LOOKUPVALUE are powerful on their own, their combined utility allows you to navigate complex, multi-table architectures (Snowflake schemas) without altering the underlying data structure.

By understanding how to leverage an intermediate table to pass search keys between disconnected datasets, you can solve complex reporting requirements efficiently. Remember, real-world data is rarely perfectly shaped; knowing how to traverse these “bridges” is an essential skill for any Data Analyst.

Continue practicing these DAX patterns to enhance your ability to handle diverse and complex data scenarios in Power BI.

References

  • Microsoft Docs: LOOKUPVALUE function (DAX)
  • Microsoft Docs: RELATED function (DAX)
  • Power BI Community: Data Modeling Best Practices
Đánh Giá Bài Viết
Tuyết Nhi

Tuyết Nhi

Tôi là Tuyết Nhi - Nữ phóng viên trẻ đến từ Hà Nội. Với niềm đam mê công nghệ, khoa học kỹ thuật, tôi yêu thích và muốn chia sẻ đến mọi người những trải nghiệm, kinh nghiệm về các lĩnh vực công nghệ, kỹ thuật... Rất mong được quý độc giả đón nhận ❤️.

Related Posts

How to Generate Unique Random Numbers in Excel: A Comprehensive Guide
Học Excel

How to Generate Unique Random Numbers in Excel: A Comprehensive Guide

Master the Excel ERROR.TYPE Function to Categorize and Fix Formula Errors
Học Excel

Master the Excel ERROR.TYPE Function to Categorize and Fix Formula Errors

How to Print A5 Pages on A4 Paper: A Complete Guide
Học Excel

How to Print A5 Pages on A4 Paper: A Complete Guide

How to Create a Professional Plan vs. Actual Chart in Excel
Học Excel

How to Create a Professional Plan vs. Actual Chart in Excel

Discussion about this post

Trending.

Hướng Dẫn Tích Hợp Akismet Vào Contact Form 7: Giải Pháp Chống Spam “Tàng Hình” Hiệu Quả Nhất

Hướng Dẫn Tích Hợp Akismet Vào Contact Form 7: Giải Pháp Chống Spam “Tàng Hình” Hiệu Quả Nhất

Trích Xuất Dữ Liệu từ Báo Cáo Power BI Đã Xuất Bản Trên Web

Trích Xuất Dữ Liệu từ Báo Cáo Power BI Đã Xuất Bản Trên Web

Hướng Dẫn Cách Livestream Trên Facebook Bằng Điện Thoại Và Máy Tính Đơn Giản, Sắc Nét Từ A-Z

Hướng Dẫn Cách Livestream Trên Facebook Bằng Điện Thoại Và Máy Tính Đơn Giản, Sắc Nét Từ A-Z

World War 2: Strategy Games – Game Chiến Thuật Thế Chiến II Hấp Dẫn Trên Mobile

World War 2: Strategy Games – Game Chiến Thuật Thế Chiến II Hấp Dẫn Trên Mobile

Share Acc The Battle Cats Miễn Phí Mới Nhất 2025: Full Uber Rare & Cat Food

Share Acc The Battle Cats Miễn Phí Mới Nhất 2025: Full Uber Rare & Cat Food

Giới Thiệu

Thủ Thuật

➤ Website đang trong quá trình thử nghiệm AI biên tập, mọi nội dung trên website chúng tôi không chịu trách nhiệm. Bạn hãy cân nhắc thêm khi tham khảo bài viết, xin cảm ơn!

Chuyên Mục

➤ TOP Thủ Thuật

➤ Chia Sẻ Kiến Thức

➤ Kênh Công Nghệ

➤ SEO

➤ Games

Liên Kết

➤ Ketquaxskt.com

➤ TOP Restaurants

➤ Here Restaurant

➤

➤

Liên Hệ

➤ TP. Hải Phòng, Việt Nam

➤ 0931. 910. JQK

➤ Email: [email protected]

Website này cũng cần quảng cáo, không có tiền thì viết bài làm sao  ” Đen Vâu – MTP ”

DMCA.com Protection Status

© 2025 Thủ Thuật - Website chia sẻ kiến thức công nghệ hàng đầu Việt Nam

No Result
View All Result
  • TOP Thủ Thuật
    • Thủ Thuật Internet
    • Thủ Thuật Máy Tính
    • Thủ Thuật Tiện Ích
    • Thủ Thuật Phần Mềm
  • Chia Sẻ Kiến Thức
    • Học Excel
    • Học Word
    • Học Power Point
  • Games
  • Kênh Công Nghệ
  • Facebook
  • WordPress
  • SEO

© 2025 Thủ Thuật - Website chia sẻ kiến thức công nghệ hàng đầu Việt Nam