sanity-plugin-computed-field
This plugin allows a field's value to be based on other fields or relationships with its document or based on external data. In other words, this field memoizes a value in a document using GROQ or APIs to lookup and custom javascript to compute the value from those GROQ results.
Go to sanity-plugin-computed-field