Using "AND" in an IIF function statement

  • Thread starter Thread starter AMFLMSC
  • Start date Start date
A

AMFLMSC

This is what I am trying to do:

I have two conditions that I want the if statement to look at.
If my CF_Premium is greater than 0 and my FLS_Premium is less than 0, add the
two values.

This is what I tried first and I get an error message:
Premium_Variance:IIF(and([CF_Premium]>0,[FLS_Premium]<0),[CF_Premium]+
[FLS_Premium],IIF(and([CF_Premium]<0,[FLS_Premium]>0),[CF_Premium]+
[FLS_Premium],0))

Then I tried this:

Premium_Variance:IIF([CF_Premium]>0 and [FLS_Premium]<0,[CF_Premium]+
[FLS_Premium],IIF([CF_Premium]<0 and [FLS_Premium]>0,[CF_Premium]+
[FLS_Premium],0))
 
If my CF_Premium is greater than 0 and my FLS_Premium is less than 0, add
the two values.

IIF([CF_Premium]>0 and [FLS_Premium]<0,[CF_Premium]+[FLS_Premium],0)
 
Your first solution is an Ecel notation for AND -- and(varA,VarB,..VarN) and
does not work in VB. However, your second solution is correct only it adds
the 2 numbers together regardless if:
CF_Premium < 0 AND FLS_Premium > 0 *** OR ***
CF_Premium > 0 AND FLS_Premium < 0

Josh D
 

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, or, else? 3
Multiple Conditions in IIf statement 4
IIf Statement 6
IIF function, multiple IIF 0
IIF statement 6
IIF statement 1
Iif Statement 5
IIf statement help 3

Back
Top