Slightly different from your approach, here I construct a new table by appending a column ("B") to `ds`, where the value is looked up from `ds2` via `ID`: lookup[x_] := Query[SelectFirst[#ID == x &], "B"]@ds2 SortBy["ID"]@ds[All, Append[#, "B" -> lookup[#ID]] &] [![enter image description here][1]][1] [1]: https://i.sstatic.net/97sZb.png