Forum

This content is now out of date.

Visit Our Community

Error Explained: Error Message: Divide by zero error encountered.

You may have come across the following error in Yellowfin when creating or using a Calculated Field:


Forum image


this simply means that the column you are trying to divide by (i.e. the denominator) contains a zero value, and in mathematical terms when you attempt to divide by zero the answer is undefined.

The way around this problem is to allow for the possibility of your column being zero by using a CASE statement with an ELSE clause that handles the zero situation in the most sensible way according to what values you would like to show.

In the below example when the column called Sales is zero then instead of calculating SUM(Sales)/Sale, the Calculated Field will return the answer of 0:


Forum image


It is worth noting that even if the denominator in your Calculated Field doesn't contain any zero values currently, and therefore is able to be successfully Validated, at some point in the future it may well contain a zero in which case you will get the Divide By Zero error. So, the moral of the story is it is best to always use a CASE statement that allows for zeroes when your Calculated Field has a division within it.

Regards,
Yellowfin Support