๐๐ฎ๐ ๐ณ: ๐ ๐ฎ๐ป๐ฎ๐ด๐ถ๐ป๐ด ๐ฅ๐ฒ๐น๐ฎ๐๐ถ๐ผ๐ป๐๐ต๐ถ๐ฝ๐ ๐ถ๐ป ๐๐๐ซ
In Power BI, relationships between tables are crucial for building complex data models. DAX allows you to harness these relationships and perform calculations across multiple tables. Today, weโll dive into how to manage relationships using DAX functions such as RELATED, RELATEDTABLE, and LOOKUPVALUE.
๐๐ฒ๐ ๐๐๐ซ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐:
1. RELATED()
What it does: Retrieves a value from a related table.
When to use: When you need to pull data from another table with a one-to-many relationship.
Example: Suppose you have a Sales table and a Products table, and you want to bring the Product Category from the Products table into the Sales table.
๐ฬฒ๐ดฬฒ๐ปฬฒ๐ฐฬฒ๐ฬฒ๐ดฬฒ๐ณฬฒ(ฬฒ๐ฟฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ[ฬฒ๐ฟฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ ฬฒ๐ฒฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ขฬฒ]ฬฒ)ฬฒ
2. RELATEDTABLE()
What it does: Returns all rows from a related table where there is a matching row in the current table.
When to use: When you want to see all related rows for a particular entry.
Example: Letโs say you have a Customers table and want to get all sales transactions for each customer from a related Sales table.
๐ฬฒ๐ดฬฒ๐ปฬฒ๐ฐฬฒ๐ฬฒ๐ดฬฒ๐ณฬฒ๐ฬฒ๐ฐฬฒ๐ฑฬฒ๐ปฬฒ๐ดฬฒ(ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ)ฬฒ
3. LOOKUPVALUE()
What it does: Returns the value from a column in another table based on a matching condition.
When to use: When you need to retrieve a specific value from another table without a direct relationship.
Example: Looking up the Sales Amount from a Sales table where the Customer ID matches:
๐ปฬฒ๐พฬฒ๐พฬฒ๐บฬฒ๐ฬฒ๐ฟฬฒ๐
ฬฒ๐ฐฬฒ๐ปฬฒ๐ฬฒ๐ดฬฒ(ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ[ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ ฬฒ๐ฐฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ]ฬฒ,ฬฒ ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ[ฬฒ๐ฒฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ ฬฒ๐ธฬฒ๐ณฬฒ]ฬฒ,ฬฒ ฬฒ๐ฒฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ[ฬฒ๐ฒฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ ฬฒ๐ธฬฒ๐ณฬฒ]ฬฒ)ฬฒ
Practical Example:
Imagine youโre working with three tables: Orders, Customers, and Products. The Orders table contains customer and product IDs but not the actual customer names or product categories. Hereโs how you can bring that information into the Orders table using DAX:
1. Adding Customer Names to Orders:
๐ฬฒ๐ดฬฒ๐ปฬฒ๐ฐฬฒ๐ฬฒ๐ดฬฒ๐ณฬฒ(ฬฒ๐ฒฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ[ฬฒ๐ฒฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ ฬฒ๐ฝฬฒ๐ฬฒ๐ฬฒ๐ฬฒ]ฬฒ)ฬฒ
2. Adding Product Categories to Orders:
๐ฬฒ๐ดฬฒ๐ปฬฒ๐ฐฬฒ๐ฬฒ๐ดฬฒ๐ณฬฒ(ฬฒ๐ฟฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ[ฬฒ๐ฟฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ ฬฒ๐ฒฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ขฬฒ]ฬฒ)ฬฒ
3. Looking Up a Discount Rate for a Product in Orders:
๐ปฬฒ๐พฬฒ๐พฬฒ๐บฬฒ๐ฬฒ๐ฟฬฒ๐
ฬฒ๐ฐฬฒ๐ปฬฒ๐ฬฒ๐ดฬฒ(ฬฒ๐ฟฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ[ฬฒ๐ณฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ]ฬฒ,ฬฒ ฬฒ๐ฟฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ[ฬฒ๐ฟฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ ฬฒ๐ธฬฒ๐ณฬฒ]ฬฒ,ฬฒ ฬฒ๐พฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ[ฬฒ๐ฟฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ ฬฒ๐ธฬฒ๐ณฬฒ]ฬฒ)ฬฒ
What are your experiences working with relationships in Power BI? Do you have any tips or challenges when using RELATED or LOOKUPVALUE? Share your thoughts in the comments!

hashtag#PowerBI hashtag#DAX hashtag#DataRelationships hashtag#DataAnalysis hashtag#PowerBItips hashtag#10DaysOfDAX