IIF alternative in query

C

ChoonBoy

I understand that using IIF expression in query can slow down the database.
Is there an alternative to the statement below as I have many IIF variants in
a single query.

Sales:
IIf([qty]="unit",[quantity],IIf([qty]="bonus",[bns],IIf([qty]="UnitBns",nz([quantity],0)+nz([bns],0),[Sale])))

Thanks in advance
 
D

Dale Fye

Take a look at the switch function. It will look something like:

Sales:Switch([qty] = "unit", value1, [qty] = "bonus", value2, [qty] =
"UnitBns", value3, True, 0)

You pass this function a series of expressions, each followed by the value
that should be returned if that expression evaluates to true. I generally
add a True, followed by some value that will indicate to you that none of the
expressions evaluated to true. If you don't do this, the function will
return a Null value.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
C

ChoonBoy

Thanks, will try this out..

Regards

Dale Fye said:
Take a look at the switch function. It will look something like:

Sales:Switch([qty] = "unit", value1, [qty] = "bonus", value2, [qty] =
"UnitBns", value3, True, 0)

You pass this function a series of expressions, each followed by the value
that should be returned if that expression evaluates to true. I generally
add a True, followed by some value that will indicate to you that none of the
expressions evaluated to true. If you don't do this, the function will
return a Null value.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



ChoonBoy said:
I understand that using IIF expression in query can slow down the database.
Is there an alternative to the statement below as I have many IIF variants in
a single query.

Sales:
IIf([qty]="unit",[quantity],IIf([qty]="bonus",[bns],IIf([qty]="UnitBns",nz([quantity],0)+nz([bns],0),[Sale])))

Thanks in advance
 

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

Similar Threads

IIF in Crosstab Expression 0
IIF statement pulling from wrong field 2
IIF Query Help 1
Query Criteria IIf statement 4
Using Nz in inventory running balance 2
IIF in query 1
IIF statement 6
IIf statement Query 17

Top