division is zero error in query

G

Guest

I am using the following calculation in one of my queries and receive the
DIVISION IS ZERO error. How can I change calculation this to accept the
answer as 0%?
I am not sure how or if I should use Nz.

Specificity %: (([Sum Of SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]))*100)

Thanks.
 
T

Tom Ellison

Dear Kate:

I expect what it is telling you is that, in at least on case:

[Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]

os zero.

I recommend this:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)], 0, [Sum
Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] =
0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100)

The above may wrap. Remove any newlines that are inserted when you paste it
in.

Tom Ellison
 
G

Guest

Thanks Tom for answering. When I run the query I get the following error:

"The expression you entered is missing a closing parenthesis, bracket (]) or
vertical bar (|).

Thanks,
Kate

Tom Ellison said:
Dear Kate:

I expect what it is telling you is that, in at least on case:

[Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]

os zero.

I recommend this:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)], 0, [Sum
Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] =
0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100)

The above may wrap. Remove any newlines that are inserted when you paste it
in.

Tom Ellison


Kate said:
I am using the following calculation in one of my queries and receive the
DIVISION IS ZERO error. How can I change calculation this to accept the
answer as 0%?
I am not sure how or if I should use Nz.

Specificity %: (([Sum Of SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]))*100)

Thanks.
 
G

Guest

If I put another parenthesis at the end of the string, i get a box asking for
a parameter value for SUM.

Kate

Tom Ellison said:
Dear Kate:

I expect what it is telling you is that, in at least on case:

[Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]

os zero.

I recommend this:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)], 0, [Sum
Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] =
0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100)

The above may wrap. Remove any newlines that are inserted when you paste it
in.

Tom Ellison


Kate said:
I am using the following calculation in one of my queries and receive the
DIVISION IS ZERO error. How can I change calculation this to accept the
answer as 0%?
I am not sure how or if I should use Nz.

Specificity %: (([Sum Of SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]))*100)

Thanks.
 
T

Tom Ellison

Dear Kate:

Please allow me to try again, maybe a bit more carefully:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] = 0, 0,
[Sum Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse
(+)] = 0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100))

I feel a bit better about it this time. 2 errors!

Tom Ellison


Kate said:
If I put another parenthesis at the end of the string, i get a box asking
for
a parameter value for SUM.

Kate

Tom Ellison said:
Dear Kate:

I expect what it is telling you is that, in at least on case:

[Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]

os zero.

I recommend this:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)], 0,
[Sum
Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]
=
0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100)

The above may wrap. Remove any newlines that are inserted when you paste
it
in.

Tom Ellison


Kate said:
I am using the following calculation in one of my queries and receive
the
DIVISION IS ZERO error. How can I change calculation this to accept
the
answer as 0%?
I am not sure how or if I should use Nz.

Specificity %: (([Sum Of SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]))*100)

Thanks.
 
G

Guest

Dear Tom:
Sorry, but I still get a Divison by Zero error. I know it is frustrating to
me as well.

Just to verify, this is what I entered:

Specificity %: IIf([Sum Of SumOfTrue (-)]+[Sum Of SumOfFalse (+)]=0,0,[Sum
Of SumOfTrue (-)]/IIf([Sum Of SumOfTrue (-)]+[Sum Of SumOfFalse (+)]=0,1,[Sum
Of SumOfTrue (-)]+[Sum Of SumOfFalse (+)]*100))




Tom Ellison said:
Dear Kate:

Please allow me to try again, maybe a bit more carefully:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] = 0, 0,
[Sum Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse
(+)] = 0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100))

I feel a bit better about it this time. 2 errors!

Tom Ellison


Kate said:
If I put another parenthesis at the end of the string, i get a box asking
for
a parameter value for SUM.

Kate

Tom Ellison said:
Dear Kate:

I expect what it is telling you is that, in at least on case:

[Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]

os zero.

I recommend this:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)], 0,
[Sum
Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]
=
0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100)

The above may wrap. Remove any newlines that are inserted when you paste
it
in.

Tom Ellison


I am using the following calculation in one of my queries and receive
the
DIVISION IS ZERO error. How can I change calculation this to accept
the
answer as 0%?
I am not sure how or if I should use Nz.

Specificity %: (([Sum Of SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]))*100)

Thanks.
 
G

Guest

I saw in another posting where someone entered there entire SQL Statement so
I will do that too to see if that helps.

SELECT [Total Findings Query].[Date By Month], ([Sum Of SumOfTrue (+)]+[Sum
Of SumOfTrue (-)])/([Sum Of SumOfTrue (+)]+[Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]+[Sum Of SumOfFalse (-)])*100 AS [Accuracy %], [Sum Of
SumOfTrue (+)]/([Sum Of SumOfTrue (+)]+[Sum Of SumOfFalse (-)])*100 AS
[Sensitivity %], (([Sum Of SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]))*100) AS [Specificity %], Year([Total Findings Query].[Date
By Month])*12+DatePart('m',[Total Findings Query].[Date By Month])-1 AS
Expr1, [Total Findings Query].[SumOf# of Patient's seen], [Total
Calculations]![Total Stressed]/[Total Findings Query]![SumOf# of Patient's
seen] AS [Total Cath'd]
FROM [Total Findings Query] INNER JOIN [Total Calculations] ON [Total
Findings Query].[Date By Month] = [Total Calculations].[Date By Month]
GROUP BY [Total Findings Query].[Date By Month], ([Sum Of SumOfTrue
(+)]+[Sum Of SumOfTrue (-)])/([Sum Of SumOfTrue (+)]+[Sum Of SumOfTrue
(-)]+[Sum Of SumOfFalse (+)]+[Sum Of SumOfFalse (-)])*100, [Sum Of SumOfTrue
(+)]/([Sum Of SumOfTrue (+)]+[Sum Of SumOfFalse (-)])*100, (([Sum Of
SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of SumOfFalse (+)]))*100),
Year([Total Findings Query].[Date By Month])*12+DatePart('m',[Total Findings
Query].[Date By Month])-1, [Total Findings Query].[SumOf# of Patient's seen],
[Total Calculations]![Total Stressed]/[Total Findings Query]![SumOf# of
Patient's seen]
ORDER BY Year([Total Findings Query].[Date By Month])*12+DatePart('m',[Total
Findings Query].[Date By Month])-1;

Thanks
Kate

Tom Ellison said:
Dear Kate:

Please allow me to try again, maybe a bit more carefully:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] = 0, 0,
[Sum Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse
(+)] = 0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100))

I feel a bit better about it this time. 2 errors!

Tom Ellison


Kate said:
If I put another parenthesis at the end of the string, i get a box asking
for
a parameter value for SUM.

Kate

Tom Ellison said:
Dear Kate:

I expect what it is telling you is that, in at least on case:

[Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]

os zero.

I recommend this:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)], 0,
[Sum
Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]
=
0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100)

The above may wrap. Remove any newlines that are inserted when you paste
it
in.

Tom Ellison


I am using the following calculation in one of my queries and receive
the
DIVISION IS ZERO error. How can I change calculation this to accept
the
answer as 0%?
I am not sure how or if I should use Nz.

Specificity %: (([Sum Of SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]))*100)

Thanks.
 
T

Tom Ellison

Dear Kate:

SELECT [Total Findings Query].[Date By Month],
([Sum Of SumOfTrue (+)]+[Sum Of SumOfTrue (-)]) /
([Sum Of SumOfTrue (+)] + [Sum Of SumOfTrue (-)] +
[Sum Of SumOfFalse (+)] + [Sum Of SumOfFalse (-)]) * 100
AS [Accuracy %],
[Sum Of SumOfTrue (+)] / ([Sum Of SumOfTrue (+)] +
[Sum Of SumOfFalse (-)])*100 AS [Sensitivity %],
(([Sum Of SumOfTrue (-)] / ([Sum Of SumOfTrue (-)] +
[Sum Of SumOfFalse (+)])) * 100) AS [Specificity %],
Year([Total Findings Query].[Date By Month]) * 12 +
DatePart('m', [Total Findings Query].[Date By Month]) - 1
AS Expr1,
[Total Findings Query].[SumOf# of Patient's seen],
[Total Calculations] ! [Total Stressed] /
[Total Findings Query]![SumOf# of Patient's seen] AS [Total Cath'd]
FROM [Total Findings Query]
INNER JOIN [Total Calculations]
ON [Total Findings Query].[Date By Month] = [Total Calculations].[Date
By Month]
GROUP BY [Total Findings Query].[Date By Month],
([Sum Of SumOfTrue (+)] + [Sum Of SumOfTrue (-)]) /
([Sum Of SumOfTrue (+)]+[Sum Of SumOfTrue (-)] +
[Sum Of SumOfFalse (+)] + [Sum Of SumOfFalse (-)]) * 100,
[Sum Of SumOfTrue (+)] / ([Sum Of SumOfTrue (+)] +
[Sum Of SumOfFalse (-)])*100,
(([Sum Of SumOfTrue (-)] / ([Sum Of SumOfTrue (-)] +
[Sum Of SumOfFalse (+)]))*100),
Year([Total Findings Query].[Date By Month]) * 12 +
DatePart('m', [Total Findings Query].[Date By Month]) - 1,
[Total Findings Query].[SumOf# of Patient's seen],
[Total Calculations]![Total Stressed] /
[Total Findings Query]![SumOf# of Patient's seen]
ORDER BY Year([Total Findings Query].[Date By Month]) * 12 +
DatePart('m',[Total Findings Query].[Date By Month])-1

Whew!

Now, please look at each and every place where you have a division (/) in
your query. Each and every one will need a modification like the one I
proposed.

I tested the code I gave you, using 5 and -5 for the SumOfTrue and
SumOfFalse, so their sum is zero. That's why it would be dividing by zero,
right? Well, the code I wrote gives 0 for this, not an error. However,
every place in your code where you have division is a candidate for the
cause of this error.

If you change every one of these divisions it may fix the problem. If you
have trouble with that, I will consider looking at your actual database to
propose a solution, if you choose. Don't sent it yet, work at it more
first. You'll need instructions from me before sending it.

Tom Ellison


Kate said:
I saw in another posting where someone entered there entire SQL Statement
so
I will do that too to see if that helps.

SELECT [Total Findings Query].[Date By Month], ([Sum Of SumOfTrue
(+)]+[Sum
Of SumOfTrue (-)])/([Sum Of SumOfTrue (+)]+[Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]+[Sum Of SumOfFalse (-)])*100 AS [Accuracy %], [Sum Of
SumOfTrue (+)]/([Sum Of SumOfTrue (+)]+[Sum Of SumOfFalse (-)])*100 AS
[Sensitivity %], (([Sum Of SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of
SumOfFalse (+)]))*100) AS [Specificity %], Year([Total Findings
Query].[Date
By Month])*12+DatePart('m',[Total Findings Query].[Date By Month])-1 AS
Expr1, [Total Findings Query].[SumOf# of Patient's seen], [Total
Calculations]![Total Stressed]/[Total Findings Query]![SumOf# of Patient's
seen] AS [Total Cath'd]
FROM [Total Findings Query] INNER JOIN [Total Calculations] ON [Total
Findings Query].[Date By Month] = [Total Calculations].[Date By Month]
GROUP BY [Total Findings Query].[Date By Month], ([Sum Of SumOfTrue
(+)]+[Sum Of SumOfTrue (-)])/([Sum Of SumOfTrue (+)]+[Sum Of SumOfTrue
(-)]+[Sum Of SumOfFalse (+)]+[Sum Of SumOfFalse (-)])*100, [Sum Of
SumOfTrue
(+)]/([Sum Of SumOfTrue (+)]+[Sum Of SumOfFalse (-)])*100, (([Sum Of
SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum Of SumOfFalse (+)]))*100),
Year([Total Findings Query].[Date By Month])*12+DatePart('m',[Total
Findings
Query].[Date By Month])-1, [Total Findings Query].[SumOf# of Patient's
seen],
[Total Calculations]![Total Stressed]/[Total Findings Query]![SumOf# of
Patient's seen]
ORDER BY Year([Total Findings Query].[Date By
Month])*12+DatePart('m',[Total
Findings Query].[Date By Month])-1;

Thanks
Kate

Tom Ellison said:
Dear Kate:

Please allow me to try again, maybe a bit more carefully:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] = 0,
0,
[Sum Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse
(+)] = 0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100))

I feel a bit better about it this time. 2 errors!

Tom Ellison


Kate said:
If I put another parenthesis at the end of the string, i get a box
asking
for
a parameter value for SUM.

Kate

:

Dear Kate:

I expect what it is telling you is that, in at least on case:

[Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)]

os zero.

I recommend this:

Specificity %: IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)],
0,
[Sum
Of SumOfTrue (-)] / IIf([Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse
(+)]
=
0, 1, [Sum Of SumOfTrue (-)] + [Sum Of SumOfFalse (+)] * 100)

The above may wrap. Remove any newlines that are inserted when you
paste
it
in.

Tom Ellison


I am using the following calculation in one of my queries and receive
the
DIVISION IS ZERO error. How can I change calculation this to accept
the
answer as 0%?
I am not sure how or if I should use Nz.

Specificity %: (([Sum Of SumOfTrue (-)]/([Sum Of SumOfTrue (-)]+[Sum
Of
SumOfFalse (+)]))*100)

Thanks.
 

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

Similar Threads

division by zero 5
division by zero-PLEASE HELP 5
divison by zero 2
HELP WITH QUERY BY DATE 2
Division by Zero Error 1
"Division by Zero" Question 2
"Division by zero", but... 2
Division by Zero Error 4

Top