Forum Discussion
anvikuttu
4 years agoAdvocate I
Need help on M Query
Hi Team, I need your help in solving in Power query. I have 2 tables Table A and Table B. I am trying to update Table A (Result field) by searching values from Table B in Table A. If the values a...
- 4 years ago
You aren't too far off but I think I'd write it like this:
= Table.AddColumn( #"Changed Type1", "Custom", (t) => List.Last( List.Select( TableB[LookupValue], each Text.Contains(t[Test], _) ) ) ?? "Not Found", type text )The "??" part indicates what to return if the preceding expression is null.
- 4 years ago
Compute them separately and use if/then logic to return the text you want.
(t) => [ Partial = List.Last(List.Select(TableB[LookupValue], each Text.Contains(t[Test], _))), Exact = List.Last(List.Select(TableB[LookupValue], each t[Test] = _)), Text = if Exact <> null then "Exact match " & Exact else if Partial <> null then "Partial match " & Partial else "No match" ][Text]
anvikuttu
4 years agoAdvocate I
Thank AlexisOlson, my apologies for not making my question clear. I would like the output to make the distinction between Exact and partial....like for e.g. "Exact match ???" or "Partial match C/O"
Thank you for taking the effort to help me out
AlexisOlson
4 years agoSuper User
Compute them separately and use if/then logic to return the text you want.
(t) =>
[
Partial = List.Last(List.Select(TableB[LookupValue], each Text.Contains(t[Test], _))),
Exact = List.Last(List.Select(TableB[LookupValue], each t[Test] = _)),
Text =
if Exact <> null then "Exact match " & Exact
else if Partial <> null then "Partial match " & Partial
else "No match"
][Text]