This is tricky but here is a possible approach: https://public.getgrist.com/ndNH3bMWLZJD/Show-Which-Value-Changed/m/fork
The key to it is a History
column with a Trigger Formula which uses its own previous value to maintain the current and the previous value of another cell. We encode the value into JSON so that it can be stored in a data column (of type Text):
import json
history = json.loads(value) if value else []
json.dumps([$Value] + history[0:1])
It’s reevaluated whenever $Value
changes: each time it places the current $Value
as a first item in an array, and moves the previous first item to be the second item.
The Value
columns is a formula that collects all the cells of interest.
With this History
column in place, the Change
column like you want can be a regular formula column that compares the last two values in $History
:
import json
history = json.loads($History) if $History else []
if len(history) < 2:
return None
[current, previous] = history
for key in current:
if current[key] != previous[key]:
return (key, previous[key], current[key])
It still needs to decode using JSON and also to check that History contains two values that could be compared. Then it goes through all keys, and returns info about the first difference.