'Google Sheets linking two sheets using a primary key

I have two sheets that I want to link using a "primary key". At the moment, I have imported from sheet1 into sheet2 some columns using the function =Sheet1!A1 (for the first cell for instance). My purpose is to complete the data related to each imported line in sheet2. However, sheet1 is shared with other people, thus they can modify the content of a line without deleting or modifying the data I have added in sheet2 (and that doesn't exist in sheet1).

Given the fact that my table has a column 'id' that can be considered as a primary key, how can I add new data in sheet2 in so far as it will be related to the 'id' rather than the position of the line (so if I ever change an id in sheet1 the data I added will be deleted or if I move an id to another line, all the data will be moved too)?



Solution 1:[1]

you can use VLOOKUP and bring over data based on ID, like:

=ARRAYFORMULA(IFERROR(VLOOKUP(D:D, Sheet1!A1:B, 2, 0),))


for more columns add them in an array:

=ARRAYFORMULA(IFERROR(VLOOKUP(D:D, Sheet1!A1:B, {2,3,4,5}, 0),))

demo spreadsheet

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1