I think the outer dollar sign expansions has issues with the comma in the expanded inner dollar sign expansions, which will be interpreted as argument separator.
You can find some workarounds if you search this forum or the net for dollar sign expansion with arguments.
If you need the expanded aggregation only evaluated in total context (e.g. in an gauge chart or text box), you may wanna try
Here are some links that may help coping with the issue