Expression has the wrong amount of arguments

Hi

I am having some trouble with the below expression in a query. I am trying to get the average of three fields which allows for zero's.

ACWLW: ([RELTTMALW]+[AOLTTMALW]+[WTMALW])/IIf((-([RELTTMALW]<>0)-([AOLTTMALW]<>0)-([WTMALW]<>0))

It is telling me that The Expression you entered has a function containing the wrong number of arguments.

It has been a long day and I just cannot see it!! Could somebody please enlighten me :-)

Thanking you
LVL 2
ajaeclarkeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel PineaultPresident / Owner CARDA Consultants Inc.Commented:
IIF() expects 3 input variables, the criteria to test for, what to do if it is TRUE, what to do if it is FALSE.
If you explain what should be happening, we can try to further help.

Also, ypically I would use Nz([FiledName], 0)  to always ensure there is a numeric value being returned just in case a field is empty, Null which could cause errors to be thrown.
Gustav BrockCIOCommented:
You could try:

ACWLW: 
    IIf(
        Sgn(Abs([RELTTMALW])) + Sgn(Abs([AOLTTMALW])) + Sgn(Abs([WTMALW])) > 0), 
        ([RELTTMALW]+[AOLTTMALW]+[WTMALW]) / (Sgn(Abs([RELTTMALW])) + Sgn(Abs([AOLTTMALW])) + Sgn(Abs([WTMALW]))), 
        0)

Open in new window

Of course, remove linebreaks.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ajaeclarkeAuthor Commented:
You are a legend Gustav! Thank you so much. :)
Gustav BrockCIOCommented:
You are welcome!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.