Did you make this a Totals query (sigma character on ribbon)?
You might find this easier to solve by using a query to populate a temp table with the calculations, minimum number of fields related to the calculation where at least one of them is related to the main table or query and is indexed. Then join that table to a 2nd query to get the remainder. A totals query sometimes cannot be grouped while still returning the desired records.
BTW - by temp table I do not mean one that you continually recreate.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.