Calculated column which checks to see if a value in that row is in another list
-
08-02-2021 - |
Domanda
I'm trying to figure out the sharepoint equivalent to the following SQL statement:
UPDATE List1, List2 SET List1.Field2 = List2.Field2
WHERE List1.Field1 = List2.Field1;
Or the Excel version:
=VLOOKUP(List1![Field1],List2,[Field2])
I'm using sharepoint lists as data storage with a Microsoft Access file as the user interface. I have the SQL statement above saved as a query within Access, but running update queries from Access is very slow due to poor network conditions and the lists having a large number of records. I'm not sure how to accomplish this in such a way that the end user is not editing the sharepoint lists directly. Thanks.
Soluzione
Unfortunately, Calculated columns cannot directly perform lookups in other tables, and if you added a relational Lookup column, you cannot reference Lookup columns from with a Calculated column formula.
However, creating a workflow (or a Power Automate Flow, depending on which version of SharePoint you are using) would be trivial.
- Trigger your workflow on List1 item updated or modified
- Get Value of Field2 from List2 by finding item by value of Field1
- If the found value is different, then Update the value of Field2 on the triggered item
The If
condition is important here as otherwise you could get stuck in a loop where updating the Item that triggered the workflow would re-trigger another instance of the workflow and so on.