Forum Discussion
Searching a column in table A using data from a column in table B
I have a need to search a string in Column 1 from Table A with column 1 Table B so that if a match exists, it displays the value of Column 2 in Table B.
Table A = Outlook 365 Data (Subject [Text])
Table B = External Vendor Info (Name/ ID# [Text])
My goal is to create a new column that will search Table A Subject Column with any value in the ID# from Table B.
If a result is found, I want to display the Name from Table B in that new column.
I have found several posts that are close but cannot seem to find one that does this specific case scenario.
Any help is appreciated.
Michael
- Anonymous2 years ago
Hi Anonymous
"Custom1" is not created with adding a custom column. It is created in the formula bar directly just like below. You can right click #"Renamed Columns2" step, select "Insert Step After" then modify the code in the formula bar.
For the second step, it is created with adding a custom column. But it is not based on the "Custom1" step. Instead, it is based on the previous step of "Custom1". You need to modify the step name.
You can also edit the code in Advanced editor directly. It looks like this.
Best Regards,
Jing
14 Replies
- dufoq3Community Champion
Hi Anonymous, what about this?
Result (Table1 with matching ID's from Table2)
let Table1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyNjRSitWJVnJz9zAxBbMcHR3NzJRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), Table2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8vJ3VvBNrMxXcM7JzMtMVlB2dHI2NFIILE0sKkktyqlU8E1NLcnMS1fSUTI0MlaK1YFocSnNza2E63F2cTUyVohMTUTVYGJqBtfglZ+Rp+CSn6qg7ObuYWKq4JufV5KBotrcwlIpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Calendar Meeting" = _t, ID = _t]), Table2CalendarMeetings = List.Buffer(Table2[Calendar Meeting]), Ad_Table2ID = Table.AddColumn(Table1, "Table2 ID", each [ a = List.PositionOf(Table2CalendarMeetings, [Column1], Occurrence.First, (x,y)=> Text.Contains(x, y, Comparer.OrdinalIgnoreCase)), //First match position b = if a = -1 then null else Table2[ID]{a} ][b] ) in Ad_Table2ID - kpostSolution Sage
when you say "Search", do you mean that they don't have to match exactly, so you can't just do a left join?
- AnonymousNot applicable
Here is a real world example.
The subject of the calendar meeting might say "JOC Mayo Clinic #ABC12 Quarterly Meeting".
My other column from table 2 has "ABC12" and another column that has an ID of 213ABC456.
I need to search "ABC12" with the subject string in Table 1 have Table 1 display in a new column the ID from Table 2.
I have tried this -
maxx(filter( Table2, search(Table1[Program Name], Table2[Assigned Program],,0) >0 ),Table2[LOB]) but it is just giving me blanks.
Thanks!
- kpostSolution Sage
Are you guaranteed to have a hashtag before the value?
If so, could you create a custom column like this that extracts the first string following a hashtag, then do a left join on that column (given the fact that you said the second table is guaranteed to have only one match), or at least get rid of the necessity to "search" the string, and instead you can just match it exactly using a calculated column if you don't want to merge or join the tables?
In either case I think this would simplify things.
- CaelanFrequent Visitor
Hi, do you expect there to be more than 1 match for any row in table A? And if so, how do you want it to handle that?
I would merge query B with query A, and select column 2 from query B. The type of join you want would depend on what relationship you believe exists between the tables (you can test if the relationship is what you expect after, if necessary).
- AnonymousNot applicable
No, each row should only have one match.