Divide 2 calculated fields together

Hi Again :slight_smile:
I have a query where Im trying to divide decimal fields together and multiply by 100 to gather a percentage.

However what is output every time no matter how I write it is 0


If I add the fields together it works,so im confident the data isn’t 0 - but any division just Zeros…

Please help :slight_smile:

Carla maybe you have to use SUM(), not sure without looking at the broken out non-grouped data.

(SUM(CountEarly.Calculated_CountEarly) / SUM(CountStatus.Calculated_CountStatusRecs)) * 100

It’s always a good idea to wrap the divisor in a case when statement, thus avoiding dive by zero errors.

case when SUM(CountStatus.Calculated_CountStatusRecs) > 0 then
(SUM(CountEarly.Calculated_CountEarly) / SUM(CountStatus.Calculated_CountStatusRecs)) * 100

else 0 end

what values are displayed when you just display SUM(CountEarly.Calculated_CountEarly) and SUM(CountStatus.Calculated_CountStatusRecs)

1 Like


Thanks for advice

I tried the hasokeric - again showed 0

I tried aclements ‘case when’ etc and again showed 0

The SUM(CountEarly.Calculated_CountEarly) displays data just fine:


Thanks everyone - I finally foun that cast and float was the way to fix

following the below topic

Thanks so much :slight_smile:

1 Like