Hello friends,

I believe it should be an easy fix for someone who is good at casting. I appreciate your help.

My calculation is :

CAST(SUM(p.QTY) / SUM (r.QTY) AS decimal (5,2)) AS 'Forecast Accuracy'

p.QTY - Forecast Demand

r.QTY - Last Week Actual

Example

p.QTY = 2596

r.QTY = 2504

Therefore my calculation is

2596/2504 = 1.04

But I have 1.00 as a result

There is an issue with precision I believe. Does someone know how I can adjust the so that the 4 is not dropped.

Please let me know if you know.

Thank you.

## 8 Replies

I just tested against two integer columns in my own db. When the linked table did not return any data to sum, it returned a null value (int2). You can't calculate on a null value. When it did return data, it did sum those values, which then was able to be cast/converted to decimal format and used in the division calculation.

I'd still check the raw data for any given row returning a null value to make sure your SUM(QTY) calculations are actually returning data. Add two columns next to your ForecastAccuracy column - one each for:

CAST(SUM(p.QTY) AS decimal (5,2))

CAST(SUM(r.QTY) AS decimal (5,2))

Then post another screenshot of those same rows you previously posted with the NULL values.