we only have half the story here - please attach a twbx workbook so we know what the parameter is and how you plan to use the filter
also what did the error say when you clicked on The calculation contains errors
I can't figure out how to attach twbx file.
1 of 1 people found this helpful
It is happening due to your are using aggregated and non aggregated fields in your calculation.
Use below logic to get your desired output.
-sum(if [Sort By] = 'Province' Then [Sales] else 0 end)
You are receiving an error message because [Sales] is aggregated while [Sort By] is not. So, the error message is probably "cannot mix aggregate and non-aggregate comparisons....."
To resolve this error, use the ATTR function to aggregate [Sort By] field like below.
IF ATTR([Sort By]) = 'Province'
THEN -SUM([Sales]) ELSE 0
The link below will show you how to attach a packaged workbook for future questions.
Hope this helps.