6 Replies Latest reply on Jun 6, 2016 2:11 AM by tobias.korte

# Problem with IF-Function with NOT ISNULL and AND

Hello,

I tried to use the following logic in tableau:

IF not isnull([Field1]) and [Field2] ="AAA" THEN "XXX"

ELSEIF not isnull([Field1]) and [Field2] ="BBB" THEN "XXX"

ELSEIF not isnull([Field1]) and [Field2] ="CCC" THEN "XXX"

ELSE "YYY" END

But I did not get the correct results.

Regards,

• ###### 1. Re: Problem with IF-Function with NOT ISNULL and AND

Hello Tobias,

From my understanding of the above, you want to check also if [Field2] is not null right?

If that is the case you have to repeat the same for [Field2] as you did for [Field1] as follows:

IF not isnull([Field1]) and not isnull([Field2]) ="AAA" THEN "XXX"

ELSEIF not isnull([Field1]) and not isnull([Field2]) ="BBB" THEN "XXX"

ELSEIF not isnull([Field1]) and not isnull([Field2]) ="CCC" THEN "XXX"

ELSE "YYY" END

If that is not the case, would you be able to provide a sample .twbx so we can dig deaper?

Best,

B

• ###### 2. Re: Problem with IF-Function with NOT ISNULL and AND

Hi Tobias,

It would be great if you can share the workbook for this issue. Please elaborate what you want to achieve functionally. That would help to create a better calculation.

Thanks

-Ashish Chaudhari

• ###### 3. Re: Problem with IF-Function with NOT ISNULL and AND

Hi Tobias;

You may find a solution here:

'And' functions in 'If' statements

As Bassem Khalil suggested, please verify your logic steps: it's very easy to get lost when dealing with double negatives. Parentheses are your friends when grouping and clarifying operational steps!

Good luck!

--Michael

• ###### 4. Re: Problem with IF-Function with NOT ISNULL and AND

Hi Michael,

many thanks for your support. But meanwhile I have found solution using a different field instead of field 1. And I have changed the logic and got the result I expected.

I guess the first logic did not work because of 'blank cells' in field1.

Regards,

Tobias

• ###### 5. Re: Problem with IF-Function with NOT ISNULL and AND

Hi Ashish,

many thanks for your support. But meanwhile I have found solution using a different field instead of field 1. And I have changed the logic and got the result I expected.

I guess the first logic did not work because of 'blank cells' in field1.

Regards,

Tobias

• ###### 6. Re: Problem with IF-Function with NOT ISNULL and AND

Hi Bassem,

many thanks for your support. But meanwhile I have found solution using a different field instead of field 1. And I have changed the logic and got the result I expected.

I guess the first logic did not work because of 'blank cells' in field1.

Regards,

Tobias