IIF statement

G

Guest

How can I write (If [pounds] >= [cubicfeet]â€50 and if [cubicfeet] is null
use [pounds] otherwise the field is empty.

Below is what I have. I suspect I am missing the part “and if [cubicfeet] is
null†please help.
CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")
 
G

Guest

Here is the format of an Iif statement, iif(logical test, value if true,
value if false)

so depending on what you want, you need to determine where to nest your
second iif statement. I think this is what you are looking for:

CalLBS: iif([Pounds]>=[Cubicfeet]*50,[pounds],iif([cubicfeet] is
null,[pounds],"" ))
 
W

Wolfgang Kais

Hello.

Levans digital said:
How can I write (If [pounds] >= [cubicfeet]"50 and if [cubicfeet] is
null use [pounds] otherwise the field is empty.

Below is what I have. I suspect I am missing the part "and if [cubicfeet]
is null" please help.
CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")

IIf(([Pounds]>=[Cubicfeet]*50) or ([cubicfeet] is null),[pounds],Null)
 
C

Carl Colijn

In
Larry G. said:
Levans digital said:
How can I write (If [pounds] >= [cubicfeet]"50 and if [cubicfeet] is
null use [pounds] otherwise the field is empty.

Below is what I have. I suspect I am missing the part "and if
[cubicfeet] is null" please help.
CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")

Here is the format of an Iif statement, iif(logical test, value if
true, value if false)

so depending on what you want, you need to determine where to nest
your second iif statement. I think this is what you are looking for:

CalLBS: iif([Pounds]>=[Cubicfeet]*50,[pounds],iif([cubicfeet] is
null,[pounds],"" ))

Or simply use the old logic setup, thus avoiding nesting the IIf's (and
having to duplicate the [pounds] parameter);
IIf( ([pounds] >= [cubicfeet] " 50) Or ([cubicfeet] is null), [pounds], "")

However, as a note to Levans, as I and Larry already implied from your
question is that you want to use an OR in stead of an AND; USE [pounds]
IF EITHER [pounds] >= [cubicfeet]"50 OR [cubicfeet] is null

Kind regards,
Carl
 
G

Guest

Hey all you guys thanks. I tried Wolfgang/s solution and it worked perfectly.

However I used his concept to create another expression with simular outcome
but it did not work
here is my expression I want to fix:
CalKGtoLBS: IIf([Kilograms]>=[CubicMeters]*800.92,[kilograms]*2.2046)

Here is what I want to do:
Again I want to accomplish if [Kilograms]>=[CubicMeters]*800.92 or if
[cubicmeters] is null use ,[kilograms]*2.2046) otherwise use null

again my expression is missing out "or if [cubicmeters] is null" I tried
several what arnt I getting?

Here is one expression I made copycatting wolfgang's expression:
CalKGtoLBS: IIf(([Kilograms]>=[CubicMeters]*800.92 Or ([CubicMeters] Is
Null),[kilograms]*2.2046),Null)
but when I ran the query it says "Syntax error "comma" in query expression

Help

Wolfgang Kais said:
Hello.

Levans digital said:
How can I write (If [pounds] >= [cubicfeet]"50 and if [cubicfeet] is
null use [pounds] otherwise the field is empty.

Below is what I have. I suspect I am missing the part "and if [cubicfeet]
is null" please help.
CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")

IIf(([Pounds]>=[Cubicfeet]*50) or ([cubicfeet] is null),[pounds],Null)
 
W

Wolfgang Kais

Hello "Levans digital".

Levans digital said:
How can I write (If [pounds] >= [cubicfeet]"50 and if [cubicfeet] is
null use [pounds] otherwise the field is empty.

Below is what I have. I suspect I am missing the part "and if
[cubicfeet] is null" please help.
CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")
IIf(([Pounds]>=[Cubicfeet]*50) or ([cubicfeet] is null),[pounds],Null)
Hey all you guys thanks. I tried Wolfgang/s solution and it worked
perfectly.

However I used his concept to create another expression with simular
outcome but it did not work Here is my expression I want to fix:
CalKGtoLBS: IIf([Kilograms]>=[CubicMeters]*800.92,[kilograms]*2.2046)

Here is what I want to do:
Again I want to accomplish if [Kilograms]>=[CubicMeters]*800.92 or if
[cubicmeters] is null use [kilograms]*2.2046) otherwise use null

again my expression is missing out "or if [cubicmeters] is null" I tried
several what arnt I getting?

Here is one expression I made copycatting wolfgang's expression:
CalKGtoLBS: IIf(([Kilograms]>=[CubicMeters]*800.92 Or ([CubicMeters] Is
Null),[kilograms]*2.2046),Null)
but when I ran the query it says "Syntax error "comma" in query
expression

There are too many closing brackets. Delete the bracket in "2.2046),Null".
 

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