BAQ - Calculated Field Returning 0 or 1

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!

image

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) )

Wonderful, that worked out and returned my values just as I wanted them. Thank you very much!!

1 Like

Watch out for null and divide by zero issues.

may not be applicable here, but you never know.

1 Like