Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jayjay0306
Helper III
Helper III

lookup through multiple tables

Hi people,

I hope you can help me with a challenging task in making a calculated table in Power BI:

I have a data model loooking like this:

Datamodel MO weight.PNG

My challenge is an effort to make a calculated table looking like this:

 

Datamodel MO weight2.PNG

my problem is, that in order to consolidate "Product Name" and "Customer Name" in the same table, I need to look them up through the Sales (Fact) table.

I have made an attempt in the following DAX script, where I start out with the use of a SUMMARIZE() function to build a table on the "Product"-attributes. But I can't figure out how to add the "Customer"-attributes to the table, when the relation between the two goes thorough the "Sales"-table?

This is my DAX code:

Table = SUMMARIZE('D_Product','D_Product'[Product Key],'D_Product'[Product Name],

"Customer_key", 

VAR RelatedValues_table_prod = 
    FILTER(
        RELATEDTABLE('F_Sales'),
        VALUE('F_Sales'[PRODUCT KEY]) = VALUE(RELATED('Product'[PRODUCT_KEY]))
    )
VAR RelatedValues_table_cust = 
    FILTER(
        RELATEDTABLE('F_Sales'),
        VALUE('F_Sales'[CUSTOMER KEY]) = VALUE(RELATED('D_Customer'[CUSTOMER KEY]))
    )
RETURN
    MAXX(RelatedValues_table_cust, 'F_Sales'[CUSTOMER_KEY]),
    
    "Product key",

    VAR RelatedValues_table_prod = 
    FILTER(
        RELATEDTABLE('F_Sales'),
        VALUE('F_Sales'[PRODUCT KEY]) = VALUE(RELATED('D_Product'[PRODUCT_KEY]))
    )
VAR RelatedValues_table_cust = 
    FILTER(
        RELATEDTABLE('KPI Sell In'),
        VALUE('KPI Sell In'[CUSTOMER_KEY]) = VALUE(RELATED('Customer'[CUSTOMER_KEY]))
    )
RETURN
    MAXX(RelatedValues_table_prod, 'KPI Sell In'[PRODUCT_KEY])
)

 To be honest, I am not quite sure how to cóntinue from here?

Can it be done?

Any help or guidance is much appreciated.

Thanks.

 

Br,

JayJay0306

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, I am not sure if I understood your question correctly, but if your target to create the calculated table that looks like above, please check the below picture and the attached pbix file if it suits your requirement. It is for creating a new table.

Jihwan_Kim_0-1698943227996.png

 

Jihwan_Kim_1-1698943328205.png

 

New Table =
ADDCOLUMNS (
    F_Sales,
    "@Product Name", RELATED ( D_Product[Product Name] ),
    "@Customer Name", RELATED ( D_Customer[Customer Name] )
)

 

 

 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
jayjay0306
Helper III
Helper III

off course jiwhan_Kim, thanks 🙂

Jihwan_Kim
Super User
Super User

Hi, I am not sure if I understood your question correctly, but if your target to create the calculated table that looks like above, please check the below picture and the attached pbix file if it suits your requirement. It is for creating a new table.

Jihwan_Kim_0-1698943227996.png

 

Jihwan_Kim_1-1698943328205.png

 

New Table =
ADDCOLUMNS (
    F_Sales,
    "@Product Name", RELATED ( D_Product[Product Name] ),
    "@Customer Name", RELATED ( D_Customer[Customer Name] )
)

 

 

 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.