Conditional Statement Help

lwilt

Board Regular
Joined
May 16, 2013
Messages
187
I'm trying to run a conditional statement in an access query. The options would be:

0-100 5
101-200 10
201-300 15

ect...something like that.

I tried IIF(([FIELD]>201),15,IIF([FIELD]>=101) and ([FIELD]<201),10))

But it's not working...any help would be great
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
got it to work

Pt: IIf(([Avg Order]>601),5,(IIf([Avg Order]>=351 And ([Avg Order]<601),4)))

but now I can't get it to allow me to continuing the nested statements...help
 
Upvote 0
tried
Pt: IIf(([Avg Order]>=601),5,(IIf([Avg Order]>=351 And ([Avg Order]<601),4)),(IIF([Avg Order]>=201 And ([Avg Order]<351),3))

didnt work
 
Upvote 0
Once an IIF statement condition is True, it stops there, so you do not need the "AND" part of your formulas. Just keep moving from bigger to smaller, i.e.
Code:
[COLOR=#333333]Pt: IIf([Avg Order]>=601),5,IIf([Avg Order]>=351,4,IIF([Avg Order]>=201,3,...)))[/COLOR]
 
Upvote 0
Could you show me where I messed up my statement...keep getting an error trying to put it in and can't figure where I screwed up.

Pt:IIF([Avg Order]>=601),5,IIF(Avg Order]>=351,4,IIF([Avg Order]>=201,3,IIF([Avg Order]>=100,2,IIF([Avg Order]>0,1))))
 
Upvote 0
You have a right parend in the middle of your first IIF statement, which shouldn't be there.
You are also fish the left square bracket in front of "Avg Order" in your second IIF.
Lastly, you do not have a False condition in your last IIF (what to return if none of the conditions are met). You can leave that blank, if you like, but if you do, it will return FALSE if no conditions are met.

So your formula should look like this:
Code:
Pt:IIF([Avg Order]>=601,5,IIF([Avg Order]>=351,4,IIF([Avg Order]>=201,3,IIF([Avg Order]>=100,2,IIF([Avg Order]>0,1,0)))))
Note I have it returning 0 if none of the conditions are met.
 
Upvote 0

Forum statistics

Threads
1,215,759
Messages
6,126,731
Members
449,333
Latest member
Adiadidas

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top