Avoid #Error Value In Query

G

Guest

I Got a Query that is Calculating the True Average of the 5 Days of the Week by Product.
What happen is, some products can be 0 at the end of the week(Product not Produced), but i stiil have to put a 0 in the Field
Simple Question:
The Problem is if all Values of the week r 0, it Wiil Return #Error

i Using:
Avg Of Rump: IIf(IsError(Sum([Rump])/Sum(Abs([Rump]>0)))=True,0,Sum([Rump])/Sum(Abs([Rump]>0)))

But the sintax is wrong(i Think!!!)
i haved try This as Well:
Avg Of Rump: IIf((Sum([Rump])/Sum(Abs([Rump]>0)))="#Error",0,Sum([Rump])/Sum(Abs([Rump]>0)))

I Open to New Ideias
Thank u..
 
A

Allen Browne

You could use IsError(), rather than comparing the result to the text
"#Error".

However, the source of the problem is that you cannot divide by zero:
IIF(Sum(Abs([Rump]))=0, 0, ... calculation here)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Roy said:
I Got a Query that is Calculating the True Average of the 5 Days of the Week by Product.
What happen is, some products can be 0 at the end of the week(Product not
Produced), but i stiil have to put a 0 in the Field
Simple Question:
The Problem is if all Values of the week r 0, it Wiil Return #Error

i Using:
Avg Of Rump: IIf(IsError(Sum([Rump])/Sum(Abs([Rump]>0)))=True,0,Sum([Rump])/Sum(Abs([Rump
]>0)))

But the sintax is wrong(i Think!!!)
i haved try This as Well:
Avg Of Rump: IIf((Sum([Rump])/Sum(Abs([Rump]>0)))="#Error",0,Sum([Rump])/Sum(Abs([Rump]>0
)))

I Open to New Ideias
Thank u..
 

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