division by zero in crystal reports

mkramer777
mkramer777 used Ask the Experts™
on
Why is the following formula giving me a division by zero error and how do I fix it?

EMSD.OnRoadLoaded}+{EMSD.OnRoadUnLoaded} / {EMSD.udNOofGallons
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
Try this.  Also you need ( ) around the numerator so they are added before the divide

If  {EMSD.udNOofGallons} = 0 then
    0
Else
    ({EMSD.OnRoadLoaded}+{EMSD.OnRoadUnLoaded}) / {EMSD.udNOofGallons}

Open in new window


mlmcc

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial