Forum Discussion
Shan_Drex12
5 years agoHelper I
If Statement with Custom column (yes or no)
Hi All, I have two tables here, That I want to merge together Table1 Number Sector 2378 Vision 8908 Clothing 2311 Vision , Table2 EntryNumber Sector 2378 Visio...
Jimmy801
5 years agoCommunity Champion
Hello Shan_Drex12
you can use Table.MatchAnyRows to do that. However I had to rename the columns before feeding this function. Here the code that contains both of your tables and the function i mentioned. Check it out
let
Table1 = let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI2t1DSUQrLLM7Mz1OK1YlWsrA0AIk45+SXZGTmpYPFjIwNDZFUxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Number = _t, Sector = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", Int64.Type}, {"Sector", type text}})
in
#"Changed Type",
Table2 = let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI2t1DSUQrLLM7Mz1OK1YlWMjE1A4k45+SXZGTmpYPFjIwNDZFUxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [EntryNumber = _t, Sector = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"EntryNumber", Int64.Type}, {"Sector", type text}})
in
#"Changed Type",
CheckTable2Matches = Table.AddColumn
(
Table1,
"is entry in table 2",
(add)=> Table.MatchesAnyRows(Table.RenameColumns(Table2, {{"EntryNumber", "Number"}}), each _ = add ),
type logical
)
in
CheckTable2Matches
This is the output
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Shan_Drex12
5 years agoHelper I
Thanks Jimmy801 quick question. Would this work if its two data sets. Would I have to merge the columns based on a full outer join on "Number" to keep everything and then do this custom column formula?