View Full Version : Worked fine until added IIF


Amileaux
04-15-2004, 06:24 AM
The following is on a query I am using to calculated percentages:

Switch % Capacity Utilized: 1-([Switch Ports Available]/[Switch Total Ports Turned Up])

Because I have some instances where the divisor is a zero, I was getting "Error" - so I revised the above to:

Switch % Capacity Utilized: IIf([switch total ports turned up]=0,"0",1-([Switch Ports Available]/[Switch Total Ports Turned Up]))

Now none of the fields format correctly AND I get alot of percentages with "E", where previously there was no problem:

8.33333333333334E-02

Any thoughts as to what is causing this? Marie

dcx693
04-15-2004, 07:05 AM
Why are you having the IIF function return a "0" as a string? Why not use the number 0? I've noticed some weirdness when mixing string and numerical results from IIF functions. I never took the time to investigate what the cause was.

Amileaux
04-15-2004, 12:49 PM
Why are you having the IIF function return a "0" as a string? Why not use the number 0? I've noticed some weirdness when mixing string and numerical results from IIF functions. I never took the time to investigate what the cause was.


You are correct - that was the problem - as soon as I removed the quotes from around the zero it worked! thanks. Marie