Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How many criteria can given using "And" logic in IF condition?

I have following script which is not working Properly as i have used three Conditions using "AND" .It works good when i use two condition with one "AND". Is there solution to for applying three criteria in IF condition?

if((Not IsNull("Customer Name Today") and Not IsNull("Customer Name Yesterday") and [Customer Name Today]=[Customer Name Yesterday]),'No Change',

if((Not IsNull("Customer Name Today") and Not IsNull("Customer Name Yesterday") and [Customer Name Today]<>[Customer Name Yesterday]),'Change',

Could any one please help me to work on the right approach towards this issue ?


Thanks

4 Replies
rubenmarin

Hi Moni, there should be no problem using many "ands", what it's happening and what's the expected result?

You can create a simple table to check the data and see what is happening:

Dimensions (check in both 'supress null values'):

- "Customer Name Today"

- "Customer Name Yesterday"

Expression:

If("Customer Name Today"="Customer Name Yesterday", 1, 0)


You can sort by expression to group them and follow the result of the conditionals.


Not applicable
Author

Hi,

This is my full formula. I need this Column should be used in the table. On using this formula it is not displaying 2nd and 3rd Condition alone.

if((IsNull("Customer New Today") and IsNull("Customer Old Yesterday")), 'No Change',

if((Not isNull("Customer New Today") and  Not IsNull("Customer Old Yesterday") and ([Customer New Today]=[Customer Old Yesterday])),'No Change',

if((Not isNull("Customer New Today") and  Not IsNull("Customer Old Yesterday") and ([Customer New Today]<>[Customer Old Yesterday])),'Change',

if((IsNull("Customer New" Today) and Not isNull("Customer Old Yesterday")),'Deletion',

if((not IsNull("Customer New Today") and IsNull("Customer Old Yesterday")),'Addition'))))) as [Customer LineType]

balar025
Creator III
Creator III

Hi,

Below might be compact one to use.

Here is your scenario  :- 

Customer New TodayCustomer Old YesterdayResult
NULLNULLNo Change
ABCABCNo Change
ABCABCDChange
NULLABCDeletion
ABCNULLAddition

Formula :-

IF((isNull([Customer New Today]) and isNull([Customer Old Yesterday])) or  [Customer New Today]=[Customer Old Yesterday],'No Change',

     if(isNull([Customer New Today]),'Deletion',

          if(IsNull([Customer Old Yesterday]),'Addition',

               'Changes'

          )

     )

)

Regards,

Ravi Balar

rubenmarin

The only typo I see is the double quotes on the 'Deletion' line:

- if((IsNull("Customer New" Today) and Not isNull("Customer Old Yesterday")),'Deletion',


Should be:

if((IsNull("Customer New Today") and Not isNull("Customer Old Yesterday")),'Deletion',


The expression posted by Ravi is more clean and easy to manage.