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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
WayneC
Regular Visitor

Use reference table column as criteria in creating custom column in primary table

This may seem simple, I have been looking at several posts here on the forum, but cannot find a solution that I can even modify to fit my situation.

I have two tables.. The primary table is used for many things and is a rather large table.  the reference table is just that, holds a few names to reference.  When adding a custom column to my Primary table, I'd like to use the reference table as criteria.

TMI: I was able to use the reference table to filter the Primary, so I got that going for me.

 

here is the line of M:

= Table.AddColumn(#"Renamed Columns", "cc_Cristian", each if Text.Contains([foreman], "Cristian") then "Yes" else "No")

 

As you can see, "Cristian" is hard-wired. I'd rather like to use the below table to have the names and just reference them in this line:

WayneC_0-1685654261748.png

 

the final result would be 4 new columns (if I can do just 1, easy to rinse and repeat) with YES or NO, like this:

WayneC_1-1685653995017.png

 

Thanks,

Wayne

 

 

2 ACCEPTED SOLUTIONS
wdx223_Daniel
Super User
Super User

=Table.FromRecords(Table.TransformRows(#"Renamed Columns",each _&Record.FromTable(#table({"Name","Value"},List.Transform({"Cristian","Melvin","Adam","Mario"},(x)=>{"cc_"&x,if Text.Contains([foreman],x) then "Yes" else "No"})))))

View solution in original post

=Table.FromRecords(Table.TransformRows(#"Renamed Columns",each _&Record.FromTable(#table({"Name","Value"},List.Transform(ReferrenceTable[NameList],(x)=>{"cc_"&x,if Text.Contains([foreman],x) then "Yes" else "No"})))))

View solution in original post

4 REPLIES 4
wdx223_Daniel
Super User
Super User

=Table.FromRecords(Table.TransformRows(#"Renamed Columns",each _&Record.FromTable(#table({"Name","Value"},List.Transform({"Cristian","Melvin","Adam","Mario"},(x)=>{"cc_"&x,if Text.Contains([foreman],x) then "Yes" else "No"})))))

Works as expected.  Is it possible to remove the hard coded names and use the name from the reference table (in the event the names change, would not want to have to search and replace them all).

WayneC_0-1685721648443.png

 

=Table.FromRecords(Table.TransformRows(#"Renamed Columns",each _&Record.FromTable(#table({"Name","Value"},List.Transform(ReferrenceTable[NameList],(x)=>{"cc_"&x,if Text.Contains([foreman],x) then "Yes" else "No"})))))

Works perfectly , thank you!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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