Forum Discussion
Ironpixel
Microsoft Employee
5 years agoMerge 2 tables using similar data to match
The title may be strange, but the essence will hopefully become clear. I am using Power BI - Tranform Data so Power Query I have two tables: Table 1 User Name Team Number John /13575/6...
- 5 years ago
Ironpixel , Try a new column in Dax Like this
maxx(filter(Table2, search(table2[Team Number], table1[eam Number],,0)>0),Table2[Team Name])
- 5 years ago
Hi, Ironpixel , you might want to try such a solution,
let Lookup = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc47CoAwEATQq8jWgSXsN6W/G9iFFBaW3r81opIiYDcMj2Fyhu3Yz2GEABhJTFBdiB09aYoEJbxi6kQkV25gfoCJfUDZqWYmxaRO1uzSj3kVdyXa2Po3SV4PQCkX", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Team Name" = _t, #"Team Number" = _t]), Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fcuxCgJBDIThd0l9EMIk2dnWwsJXWLY7wYPjBN+/MJ7Y2gQy/N8Ycns+DllEDdFCkwGnsmc3KJiEZhCuXk/KXIZcX/f1K1q0n0j/lHSk9kJNYQTPe6LLtu//EGiVOyzZa4JVWZPM+QY=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"User Name" = _t, #"Team Number" = _t]), Matchup = Table.AddColumn( Source, "Team Name", each List.Accumulate( Table.ToRecords(Lookup), {[Team Number], {}}, (s, c) => if Text.Contains(s{0}, c[Team Number], Comparer.OrdinalIgnoreCase) then {s{0}, s{1}&{c[Team Name]}} else s ){1} ), #"Expanded Team Name" = Table.ExpandListColumn(Matchup, "Team Name") in #"Expanded Team Name"
amitchandak
Super User
5 years agoIronpixel , Try a new column in Dax Like this
maxx(filter(Table2, search(table2[Team Number], table1[eam Number],,0)>0),Table2[Team Name])
- Ironpixel5 years ago
Microsoft Employee
amitchandra - This is a great solution in DAX!
I got it working. If I can't get it working in Power Query I will use this.
Thank you!