You should be able to do this using advanced aggregation, something like
=sum( aggr( YOUREXPRESSION, Site))
But, YOUREXPRESSION is really complex in your case, since you are referencing another expression in your column expression which is referencing another expression, which is referencing ....
You could try embedding all these expressions into one biiiig expression, or maybe try simplyfying your expressions (maybe by precalculating as much as possible in the script).
Hope this helps,
Thanks, as I'm only a new to QV I think that is going to be too advanced for me at the moment, but I was thinking along the same lines which is promising.
Anyway to solve the problem, I've created a duplicate table, hidden all the columns except site name and cost, limited the number of rows to 3 and sorting show it shows the top 3 sites as well as the total cost of non-compliance.
I think this will work
Can I do a set analysis on this expression, so I can show the total regardless of the selection