View Full Version : I need help with Immediate If Function


Talismanic
04-26-2001, 10:22 AM
I have an Immediate If that looks like this:

GetValue: IIf([extrate]>[pwrate], [extrate],[pwrate])

Is there a way to throw another condition in this query? I would like to evaluate another field that will have either a 1, 2 or 3 in it. So I would need to incorporate a AND/OR into this GetValue. Is this possible?

If that doesn't make sense, let me try it this way:


If OtherField has 1 or 2 do GetValue if it has a three, ignore the GetValue ImediateIF Function and place a null or at the very least a 0 in the GetValue field.

Pat Hartman
04-26-2001, 06:18 PM
GetValue: IIf(OtherField = 1 or OtherField = 2),IIf([extrate]>[pwrate], [extrate],[pwrate]),0)

The basic format for the IIf() is
IIf(condition, true path, false path)

The condition may be compound and the IIf() may be nested for either or both the true and false paths.

IIf()'s can get difficult to read when they have more than a few conditions. You can always create a function where you can use a Case statement, which is much easier to read and understand.

Talismanic
04-27-2001, 06:00 AM
I am missing soemthing because I am getting an error that says the Expression you entered has a function with the wrong number of arguments.

GetValue: IIf([EarnCode]=1 or [EarnCode]=2), IIf([extrate]>[pwrate], [extrate],[pwrate]),0)

Do you see anything wrong with the way I am doing it?

Chris RR
04-27-2001, 06:16 AM
My guess is another set of parentheses (spelling???). Try this:

GetValue: IIf(([EarnCode]=1 or [EarnCode]=2), IIf([extrate]>[pwrate], [extrate],[pwrate]),0)

Talismanic
04-27-2001, 06:22 AM
That fixed it, thanks to both of you!!!

cfmiles
10-23-2001, 07:39 AM
I don't post much... and here is why. I thought I'd share for anyone new coming out here. I use the search feature before I do anything else - and was racking my brain with a nested iif function, trying to figure out how I could possibly be messing it up. This "old" post lit a lamp in my brain and I have the problem solved.

Thanks - belatedly - for all of the help this forum provides.

BukHix
10-23-2001, 07:46 AM
cfmiles, I am he, formaly know as Talismanic and I gotta agree with you there. I just love the search feature and can usually find about 90% of everything I am looking for with it.