Expressions

pacotx

Registered User.
Local time
Today, 06:36
Joined
May 25, 2006
Messages
13
Help me what is wrong with this expression:eek: :

=IIF( [eBay Method] ="Auction",
IIF( [Start up Price] <=.99,.2,
IIF( [Start up Price] < = 9.99,.35,
IIF( [Start up Price] < =24.99,.6,
IIF( [Start up Price] < =49.99,1.2,
IIF( [Start up Price] < =199.99,2.4,
IIF( [Start up Price] < =499.99,3.6,
IIF( [Start up Price] >499.99,4.8," "
))))))),
IIF( [eBay Method] ="Buy it Now",
IIF( [Start up Price] <=9.99,.05,
IIF( [Start up Price] <=24.99,.1,
IIF( [Start up Price] <=49.99,.2,
IIF( [Start up Price] <=49.99,.25," "
))))))
 
Too many nested IIFs perhaps?

Try a Case() statement instead.
 
Last edited:
Hi -

The Switch() function also works well and reduces the amount of code. Here's an example from the debug (immediate) window:
Code:
startupprice = 123.49
x = startupprice
y = switch(x<=0.99,0.2, x<=9.99,0.35, x<=24.99, 0.6,x<=49.99,1.2,x<=199.99,2.4,x<=499.99,3.6,true,4.8)
? y
 2.4

HTH - Bob
 
If it's not working for you then obviously there is something wrong with the syntax. As pointed out, too many nested Iif's create an unreadable monster. Suggest you look at Case() statements or the Switch() function as a couple of ways of creating readable, editable code.

Bob
 

Users who are viewing this thread

Back
Top Bottom