Hello there @tobimahony
You should be able to achieve this by listing all the records in your data store, turning them into an array, and using a combo of functions (general, math, array) to modify the output the way it returns (counts) only the requested values.
These resources could help when learning more about functions: