Hi All. I’m having an issue with a BAQ calculated field returning zero’s rather than actual values, and I’m not sure how to fix it.
As you can see in the screen grab below, I’ve got a calculated field to show a percent (in decimal form) but it still returns a zero rather than the actual value (24 divided by 28 should return .85 not 0.) Any help appreciated!
It’s a “Type” issue. Somewhere in your calculations SQL thinks there’s an integer (either of those first columns could be integers). So you need to cast the field as a decimal before you do the math on it.
CAST(field1 AS DECIMAL(7,2) )/CAST(field2 AS DECIMAL(7,2) )