5 Replies Latest reply on May 23, 2020 2:06 PM by Jonathan Drummey

# Multiple IF and ISNULL

Hi Community

I am trying to sort a formula but just unable to figure out the correct structure

I have three fields and i have created a calculated field to test if any of this has a value it should populate the calculated field. I am also testing if there is a null in any of these fields, if they are null it can check for other fields to find the value.

IF (ISNULL([Costelementfor supplier]))

or (isnull([Vendor Sum Name]))

OR (ISNULL([Summary Name]))

THEN

[Summary Name] ELSE[Vendor Sum Name]

END

• ###### 1. Re: Multiple IF and ISNULL

Hi,

In the given formula the logic is currently:

In a given row if any of costelementforsupplier, vendor sum name, or summary name are NULL then return the summary name, else return the vendor sum name.

How would you like it to be different?

Jonathan

• ###### 2. Re: Multiple IF and ISNULL

Hi Jonathan

May be i dint explain it correctly. Basically i want to check for null in all three fields, and if and then if either is not null then select that field as my ans. In above, due to THEN and ELSE i can only choose 2 out of three options and thus if both are null and costelementfor supplier has value, that is not populated.

How do i check for all three?

• ###### 3. Re: Multiple IF and ISNULL

Hi,

I'm still not totally sure what you are trying to do here... I *think* it might be something like:

IF NOT ISNULL([field1]) THEN

[field1]

ELSEIF NOT ISNULL([field2]) THEN

[field2]

ELSEIF NOT ISNULL([field3]) THEN

[field3]

ELSE

NULL

END

The ELSE NULL part is actually optional in Tableau, it imputes an "ELSE NULL" if there is no ELSE statement.

This can even be shortened to:

IFNULL([field1],IFNULL([field2],[field3]))

If this doesn't answer your question then please provide some sample data and a description of the output you are attempting to achieve. Mocking up several rows in MS Excel would be enough, I think. Please see Packaged workbooks and flows (and Tableau Public links): when, why, how for more info on why we ask for sample data & packaged flows.

Jonathan

1 of 1 people found this helpful
• ###### 4. Re: Multiple IF and ISNULL

Thanks Jonathan

this answers the question - i was having trouble with multiple IF and was not aware about NULL  for ELSE .

Cheers

• ###### 5. Re: Multiple IF and ISNULL

you're welcome!