if statement

T

ty

In a select query, can I place an if statement for a
calculated field. If so I need one that says if MyCount =
0, then return "Not Applicable", else [MyValue]/[MyCount].

I'm basically calculating a percentage, but can't do it if
the MyCount is zero.
 
F

Fredg

Exp: IIf(MyCount = 0,"Not Applicable",MyValue/MyCount)

The next line will also convert a Null to 0 and then work as above:

Exp:IIf(Nz(MyCount,0) = 0,"Not Applicable",MyValue/MyCount)

Take your pick.
 

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