Syntax Error in Calculated Field

Hi all.

I’m sure this will be an easy one for most of you, but I’m not fluent in C#.

As the title says, I have a calculated field in a BAQ that I can’t quite find the right syntax for. Can someone tell me why the uncommented code in this screenshot works fine, but when I try to use it in a condition statement (the commented code), it errors out?

Here is the code for usability:

replace(convert(nvarchar, round((MonthlySalesRunning.Calculated_DivisionTotal / TotDivBudgNeg * 100), 2, 4)), '0000', '')  + '%'

---(case when MonthlySalesRunning.Calculated_DivisionTotal is null then '0.00%' else replace(convert(nvarchar, round((MonthlySalesRunning.Calculated_DivisionTotal / TotDivBudgNeg * 100), 2, 4)), '0000', '')  + '%')

Thank you in advance!

Missing an END statement at the end.

1 Like

Or even better, if someone can illuminate a better way to display the result as a percentage without 6 decimal places and with a percent sign, that would be great too!

change your data type to a decimal. then in format enter >>9.99%

That will automatically turn it into a percentage and then round to 2 decimal places. Or whatever you want.

2 Likes

OMG, it is that easy. Doh!