I've found personally it's better to use AI to build a deterministic script for calculations like that. (anything that manipulates data should be a script not an AI).
Because I was already doing categorising and analysing same data with agent and I had my session open already. It should've been an easy task for an agent, right?