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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors