**Issue:**

While working with expressions. Especially when there are calculations being made by dividing one Y axis by another, one will always encounter divide by zero errors wherever the divided by axis (denominator) contains either nulls or zeros. The following message pops up on the chart.

in 7.5 and earlier

In 8.0:

In 8.5 and newer:

# Resolution:

Within the expression one will have to add checks wherever the values are null or zero to avoid such divide by zero errors. You can make your expressions more robust by testing for null as well as 0 by referring to the below example.

if(y2==0 || || y2==null){

0;

}else{

(y1-y2)/y2*100;

}

Another simpler, and probably more reliable, example would be to simply test if the Boolean value of y2 is false.

if( !y2 ) {

0;

}else{

(y1-y2)/y2*100;

}

You could also include a test for y2 having the Javascript value “Not a Number” with the isNaN function.

if(!y2 || isNaN(y2)){

0;

}else{ (y1-y2)/y2*100;

}

It’s extremely unlikely that y2 would have the value NaN, however, if it came from a numeric database column. But sometimes the results of interim calculations can be NaN, so the isNaN function is good to have handy.

# Applies to:

- Eval Cloud
- Private Cloud
- Enterprise + BAM
- X Platform
- Enterprise Suite

## Comments

0 comments

Article is closed for comments.