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:
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:
Thanks,
Wayne
Solved! Go to Solution.
=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"})))))
=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"})))))
=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).
=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!