Divide By Zero in Expression Question

A

Alan Balthrop

I am working on a database for a local professional soccer team. Three
of my queries will occaisonally have values that cause a "divde by
zero" error.

Is there a way I could have the value of the field returned as ".000"
or "0.00" if this happens?

The expressions in question are formatted as such:


SVPCT: [SV]/([SV]+[GA]) (results come back as .000)
GAA: ([GA]*60)/[MIN] (results come back as 0.00)
WPCT: [W]/([W]+[L]) (results come back as .000)




Alan Balthrop
Team Historian
Dallas Sidekicks Indoor Soccer Club
(e-mail address removed)
 
G

Gary Miller

Alan,

You would just need to check to make sure that you have more
than zero to work with. An IIf statement works nicely for
this...

SVPCT: IIf([SV]+[GA] > 0,[SV]/([SV]+[GA]),0)

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
A

Alan Balthrop

SVPCT: IIf([SV]+[GA] > 0,[SV]/([SV]+[GA]),0)

GarryL

Thank you for the advise on the code. The above code works great for
the SVPCT issue, but when I attempt to adapt it for WPCT, there is
still #error appearing.

ex:

WPCT: IIf([W]/([W]+[L])>0,[W]/([W]+[L]),0)

The code, when used for SVPCT works perfectly, for WPCT still returns
an #error if the goalkeeper had a record of 0 wins and 0 losses. What
I am doing wrong?
 
G

Gary Miller

Alan,

The larger concept of what I am testing for in the IF
statement is 'IF the divisor is greater than zero then do
the division, IF NOT give us a Zero so we don't get the
error that we were dividing by zero'.

The difference between your line and mine is that you
included the whole dividing formula in the first section of
the IF, which is the test line, where I only tested for what
was the divisor section to the right of the dividing
symbol.. "/".


--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
Alan Balthrop said:
SVPCT: IIf([SV]+[GA] > 0,[SV]/([SV]+[GA]),0)

GarryL

Thank you for the advise on the code. The above code works great for
the SVPCT issue, but when I attempt to adapt it for WPCT, there is
still #error appearing.

ex:

WPCT: IIf([W]/([W]+[L])>0,[W]/([W]+[L]),0)

The code, when used for SVPCT works perfectly, for WPCT still returns
an #error if the goalkeeper had a record of 0 wins and 0 losses. What
I am doing wrong?
 
G

Gary Miller

Sorry, I forgot to include the corrected line for WPCT...

WPCT: IIf(([W]+[L])>0,[W]/([W]+[L]),0)


--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
Gary Miller said:
Alan,

The larger concept of what I am testing for in the IF
statement is 'IF the divisor is greater than zero then do
the division, IF NOT give us a Zero so we don't get the
error that we were dividing by zero'.

The difference between your line and mine is that you
included the whole dividing formula in the first section of
the IF, which is the test line, where I only tested for what
was the divisor section to the right of the dividing
symbol.. "/".


--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
Alan Balthrop said:
SVPCT: IIf([SV]+[GA] > 0,[SV]/([SV]+[GA]),0)

GarryL

Thank you for the advise on the code. The above code
works
great for
the SVPCT issue, but when I attempt to adapt it for
WPCT,
there is
still #error appearing.

ex:

WPCT: IIf([W]/([W]+[L])>0,[W]/([W]+[L]),0)

The code, when used for SVPCT works perfectly, for WPCT still returns
an #error if the goalkeeper had a record of 0 wins and 0 losses. What
I am doing wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top