It’s best to not use calculated attributes if at all possible as they are calculated for every single access and can’t be used for sorting or filtering.
In your example, I would look at refactoring the calculated attribute so it’s a regular stored attribute. You can generate and store this when another attribute in the entity is changed. One approach could be using a before commit event handler on the entity, so you know whenever data is stored to the database, the field will be regenerated and available for use.
I hope this helps.