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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jmvidal
Helper II
Helper II

Geting a field from a related table in a one to many relationship.

Hi,

I need to retrieve the field value from Table2 when option=sector, in order to build Table3 from Table1 and Table2.

LOOKUPVALUE is working fine, but wonder if it wouldn't be more eficient using RELATED or RELATEDTABLE, as far as those tables are linked throught the customer field.

Thanks,

 

Table1

customercountry
1USA
2UK
3China

 

Table2

customeroptionvalue
1sectorconstruction
1sizesmall
2sectoragriculture
2typeprivate
3sector

construction

 

Table3

customercountrysector
1USAconstruction
2UKagriculture
3Chinaconstruction
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @jmvidal 

I use Power query to create the Table3

Capture4.JPG

make a duplicate table of Table2,

remove other columns,

then select "Option' column in Table3, pivot column,

Capture5.JPG

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
v-juanli-msft
Community Support
Community Support

Hi @jmvidal 

I use Power query to create the Table3

Capture4.JPG

make a duplicate table of Table2,

remove other columns,

then select "Option' column in Table3, pivot column,

Capture5.JPG

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes! Using Pivot coulmn I created a new table that I added I to the schema linked to the original table by the customer code.

Thank you very much.

v-juanli-msft
Community Support
Community Support

Hi @jmvidal 

Do you want to create a physical table or a table only to show the result as "Table3"?

If you could accept to create measures and finally show these via a table visual, it could perform well than a calculated table.

 

Best Regards
Maggie

Table 3 containing Table 1 and Table 2 info is not just a visual: it will be used to perform queries as well.

Thanks,

amitchandak
Super User
Super User

If table 1 has unique customers, then you can join table 1 and table 2 on customers and in visual , you can visual level filter for sector.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you @amitchandak 

Please check my reply to previous solution regarding the several columns I need to insert and the imposibility to use just one filter.

 

There are few solution.

1. You could have pivot these two columns. But that will give you 50 Columns.

2. Use lookup or a formula like this. Again that will give you 50 columns

New column in Table 1 = maxx(filter(table2,table2[customer] = table1[customer] && table2[option]="construction",table2[value])

3. The formula above can also work as a measure. At line customer level. I did not try but should work. Here you should able to pass the second value as parameter.

 

Measure = maxx(filter(table2,table2[customer] = max(table1[customer]) && table2[option]="construction",table2[value])

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak , 

Any Idea if this would perform better than LOOKUPVALUE?

 

Mariusz
Community Champion
Community Champion

Hi @jmvidal 

 

Please see the attached file with two solutions one using CALCULATE and second Power Query.

 

And yes RELATED and RELATEDTABLE will perform better than the LOOKUPVALUE.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

 

 

 

Hi again @Mariusz ,

Thank you for your answer.

I made the question incomplete: I really need to add not just sector but also size and type, in the example (in real life I have 50 others to add)

Also customers table have many other columns.

For that reason the filter you suggested to use in the Power Query solution and Dax looks to me won't be enough...

I wish I had a solution similar to LOOKUPVALUE where I could select the desired column value together with the filter column&value.

Thanks

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.