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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Bublic
New Member

Add Column based on other table columns value

Hi!

Need your help with simple task..

 

I have 2 tables with no relations between them:

#Table1({"ColumnA", "ColumnB"}, {{1,Green Apple },{2,Red Potato},{3,Blue Star},{4,Kung Fu Panda}})  

#Table2({"ColumnC", "ColumnD"}, {{apple, fruit},{potato, vegetable},{star, astronomical object},{kung fu, martial art}}) 

 

The goal is to add ColumnE to Table1 with this condition:

if Text.Contains(Table1[ColumnB, Table2[ColumnC]) then Table2[ColumnD] else null 

 

The result should be:

#Table1({"ColumnA", "ColumnB","ColumnE"}, {{1,Green Apple , fruit},{2,Red Potato, vegetable},{3,Blue Star, astronomical object},{4,Kung Fu Panda, martial art}})  

 

This perfectly works with manual static if blocks, but I have no idea how to automate this task using values from table.

 

Any ideas?

 

1 ACCEPTED SOLUTION
Bublic
New Member
6 REPLIES 6
Bublic
New Member

Pragati11
Super User
Super User

Hi @Bublic ,

 

Try splitting your "Column B" on spaces. So you will send up with somwhting like this:

Column B.1 Column B.2

Green          Apple

Red             Potato.....

 

Now create relationship between both of your table using Column B.2  from 1st table and Column C from 2nd table.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Column B can contain value like : "The biggest green apple all over the world". How can I guess which splitted column to use?

Hi @Bublic ,

 

In that case, you shared the wrong sample data to your issue.

Go with the option suggested by @Greg_Deckler .

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Greg_Deckler
Super User
Super User

@Bublic 

@ImkeF @edhans 

 

In DAX, this would be LOOKUPVALUE or MAXX(FILTER(...)...)


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

In my casev  LOOKUPVALUE is not working without relationship(

Helpful resources

Announcements
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.