There are two ways to use variables. I mean the scope of variable changes by adding "=" & not adding "=" at the beginning of the declaration. For example if you declare a variable by pressing (Alt + Ctrl + V) - Variable Overview Window. Something like this...(attached the image)
vSales Sum (PurchaseAmt)
vSales2 =Sum (PurchaseAmt)
Both of them looks very similar but they behave differently within QV. I mean vSales works as dollar sign expansion and vSales2 is calculated at the document level and then the value is sent to the object. However, when you are using vSales then the variable is evaluated for every dimension within your object.
In your case, I am assuming that you are using dollar sign expansion (Like vSales in above example). Then you need the below expression.