Forum Discussion
Create separate table from 3 tables
- 1 year ago
Hi Power_It_Up , There are many reasons why the Related() might not be working but a general example to using the same with your problem statement will be:
Let’s say you have these three tables:
Customer (one)
Order (many, related to Customer)
Order detail (many, related to Order)
You want a new table with:
CustomerName, OrderDate, ProductNameHere’s how you might do it:
NewTable =
SELECTCOLUMNS (
ADDCOLUMNS (
OrderDetails,
"CustomerName", RELATED (Customers[CustomerName]),
"OrderDate", RELATED (Orders[OrderDate]),
"ProductName", OrderDetails[ProductName]
),
"CustomerName", [CustomerName],
"OrderDate", [OrderDate],
"ProductName", [ProductName]
)Double-check your relationships in the model:
Customer[ID]→Order[CustomerID]
Order[ID]→OrderDetails[OrderID]
Also, Making sure you're using Related() in a table that is on the many side of the relationship (to pull from the one side).
Hope it help! Please mark this as a solution if this is helpful. To better understand please share an example pbix.
Hi Power_It_Up , There are many reasons why the Related() might not be working but a general example to using the same with your problem statement will be:
Let’s say you have these three tables:
Customer (one)
Order (many, related to Customer)
Order detail (many, related to Order)
You want a new table with:
CustomerName, OrderDate, ProductName
Here’s how you might do it:
NewTable =
SELECTCOLUMNS (
ADDCOLUMNS (
OrderDetails,
"CustomerName", RELATED (Customers[CustomerName]),
"OrderDate", RELATED (Orders[OrderDate]),
"ProductName", OrderDetails[ProductName]
),
"CustomerName", [CustomerName],
"OrderDate", [OrderDate],
"ProductName", [ProductName]
)
Double-check your relationships in the model:
Customer[ID]→Order[CustomerID]
Order[ID]→OrderDetails[OrderID]
Also, Making sure you're using Related() in a table that is on the many side of the relationship (to pull from the one side).
Hope it help! Please mark this as a solution if this is helpful. To better understand please share an example pbix.