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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Reuben
Helper III
Helper III

Add column based on two related tables

Hi all,

I'm trying to add a new column in a table that lookups in 2 different tables:

 

Table1 contains columns with Table1[ID_1] and Table1[ID_2] (among other columns), in this table I want to add a new column Table1[Product]

 

"Product" should be:

Lookup Table1[ID_1] in Table2 and if Table2[ID_1] exists, then give me the value in the column Table2[Product]

if does not exist-> Lookup Table1[ID_2] in Table3[ID_2] and return me the value in the column Table3[Product]

I´ve tryed the following:

 

Table1[Product] = iferror(related(Table2[Product]);related(Table3[Product]))
 
but the result retunrs an error.
Thank you very much for your support
 
 
1 ACCEPTED SOLUTION
CheenuSing
Community Champion
Community Champion

Hi @Reuben ,

 

Hope you have the relationship between the Table1 --> Table2 and Table1 --> Table 3

 

Try the following as calculated Column in Table1

 

ProductName = IF(ISBLANK(LOOKUPVALUE(Table2[ProductName],Table2[ID ],Table1[ID ])),LOOKUPVALUE(Table3[ProductName],Table3[ID ],Table1[ID ]),LOOKUPVALUE(Table2[ProductName],Table2[ID ],Table1[ID ]))
 
What it does if the LOOKUPVALUE FROM Table2 is blank then get the LOOKUPVALUE FROM Table3 otherwise LOOKUPVALUE FROM Table2.
 
Alternately you can change your formula as under
 
Product = IF (ISBLANK(Related(Table2[ProductName])),Related(Table3[ProductName]),Related(Table2[ProductName]))
 
Cheers
 
CheenuSing
 
 
Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
CheenuSing
Community Champion
Community Champion

Hi @Reuben ,

 

Hope you have the relationship between the Table1 --> Table2 and Table1 --> Table 3

 

Try the following as calculated Column in Table1

 

ProductName = IF(ISBLANK(LOOKUPVALUE(Table2[ProductName],Table2[ID ],Table1[ID ])),LOOKUPVALUE(Table3[ProductName],Table3[ID ],Table1[ID ]),LOOKUPVALUE(Table2[ProductName],Table2[ID ],Table1[ID ]))
 
What it does if the LOOKUPVALUE FROM Table2 is blank then get the LOOKUPVALUE FROM Table3 otherwise LOOKUPVALUE FROM Table2.
 
Alternately you can change your formula as under
 
Product = IF (ISBLANK(Related(Table2[ProductName])),Related(Table3[ProductName]),Related(Table2[ProductName]))
 
Cheers
 
CheenuSing
 
 
Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Thank you very much @CheenuSing ! thats exactly what I needed!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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