11 Replies Latest reply on Mar 17, 2016 8:55 AM by Derrick Austin

# How to write a formula with if statement

Hello,

I want to create a calculation that says if name in column "Attendee Company" is null, then give me a name from column "Covered recipient institution". I wrote this formula but it isn't working right as it shows only Null values now: IF ([Attendee company]) ='Null' then [Covered recipient institution] END. Could someone please help to write a formula correctly?

• ###### 1. Re: How to write a formula with if statement

Hey Liliya,

Instead of = 'NULL', you need to use ISNULL().

Interestingly enough NULL does not equal NULL. (It's a SQL thing)

Hope this helps!

• ###### 2. Re: How to write a formula with if statement

Hi Derek,

Thank you, one thing. When I put ISNULL() it says there is an error: "Expected 'THEN' to match 'IF" at character 0". What do i need to do here? Now I made it as this: IF ([Attendee company]) = ISNULL () then [Covered recipient institution] END. Did i enter something incorrectly? Thank you.

• ###### 3. Re: How to write a formula with if statement

Close! More like this, though:

IF ISNULL([Attendee company]) THEN [Covered recipient institution] END

• ###### 5. Re: How to write a formula with if statement

Thank you! it worked:)

• ###### 6. Re: How to write a formula with if statement

It looks like the results are showing only the values in column [Covered recipient institution] even though some values are not null in column [Attendee company]. What tweak do i need to add to the formula to show value from column [Covered recipient institution] only if column [Attendee company] has nothing?

• ###### 7. Re: How to write a formula with if statement

ISNULL should do it, if it is actually null. You may have blank data in your report, which would = ''.

Something like this maybe?

IF ISNULL([Attendee company]) OR [Attendee company] = '' THEN [Covered recipient institution] END

• ###### 8. Re: How to write a formula with if statement

Hi Derek,

Thank you, you are right, data is blank and when i put in the formula above it still didn't fix it, do you have any other suggestions? Thank you.

• ###### 9. Re: How to write a formula with if statement

Might have a hidden space?

IF ISNULL([Attendee company]) OR TRIM([Attendee company]) = '' THEN [Covered recipient institution] END

• ###### 10. Re: How to write a formula with if statement

still didn't fix it, it's probably hard to figure out without looking at actual data. It's ok, I will play around with it. Thank you!

• ###### 11. Re: How to write a formula with if statement

Haha, definitely! Feel free to post a sample twbx if you can't get it figured out!