joining two iif statements

M

Marc

I would like to combine two iif together. I am able to get the results from
a single iif statement but not successful in combining the two.

iif([cert master]!Verbiage Like "*Best Buy Gift Card*",0.008,[discount]/3*7)

iif ([cert master]!Verbiage Like "*Bath & Body Works*",0.005, [discount]/3*7)

I thought a comma would work, but it does not. If I try or it does not
calculate correctly.

Thank you
 
J

John W. Vinson

I would like to combine two iif together. I am able to get the results from
a single iif statement but not successful in combining the two.

iif([cert master]!Verbiage Like "*Best Buy Gift Card*",0.008,[discount]/3*7)

iif ([cert master]!Verbiage Like "*Bath & Body Works*",0.005, [discount]/3*7)

I thought a comma would work, but it does not. If I try or it does not
calculate correctly.

Thank you

So you want to use 3/7ths of the discount if the verbiage doesn't match either
option?

If so you need one IIF nested inside another, or, perhaps better, the builtin
Switch() function. The latter takes arguments in pairs, evaluates the pairs
left to right, and when it finds a true value in the first element returns the
second and quits. Try

Switch(([cert master]!Verbiage Like "*Best Buy Gift Card*" ,0.008,
[cert master]!Verbiage Like "*Bath & Body Works*",0.005,
True, [discount]/3*7)


You can also use nested IIF's but that can get hard to read and hard to
maintain.
 
J

John W. Vinson

I would like to combine two iif together. I am able to get the results from
a single iif statement but not successful in combining the two.

iif([cert master]!Verbiage Like "*Best Buy Gift Card*",0.008,[discount]/3*7)

iif ([cert master]!Verbiage Like "*Bath & Body Works*",0.005, [discount]/3*7)

I thought a comma would work, but it does not. If I try or it does not
calculate correctly.

Thank you

So you want to use 3/7ths of the discount if the verbiage doesn't match either
option?

If so you need one IIF nested inside another, or, perhaps better, the builtin
Switch() function. The latter takes arguments in pairs, evaluates the pairs
left to right, and when it finds a true value in the first element returns the
second and quits. Try

Switch(([cert master]!Verbiage Like "*Best Buy Gift Card*" ,0.008,
[cert master]!Verbiage Like "*Bath & Body Works*",0.005,
True, [discount]/3*7)

Sorry - had an extra ( in there, should be

Switch([cert master]!Verbiage Like "*Best Buy Gift Card*" ,0.008,
[cert master]!Verbiage Like "*Bath & Body Works*",0.005,
True, [discount]/3*7)
 

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