2 Replies Latest reply on Dec 15, 2016 10:35 PM by Nicola Prime

# Creating groups through IF / ELSEIF / AND formula

Hi All,

I am trying to create a simple formula whereby if 2 criteria are met, I want to group the data into a specific group name.

I am looking at Category which has appeared as "Null" for some of my data. Therefore I want to look at the model name for those with "Null" to determine the Category.

E.g. For the below instance, I created the following formula, called Category NP: IF ([Category] = "Null"

AND [Model Name] = "DC")

THEN "Group A"

ELSE [Category]

END

However, as you can see from the above, this is not working, as it is still showing the Category NP are Null, not Group A...What am I doing wrong here?

As I have a number of these instances, I will need to create and ELSEIF portion to my formula...is the below, the right way to go about this?

IF ([Category] = "Null"

AND [Model Name] = "DC")

THEN "Group A"

ELSEIF ([Category] = "Null"

AND [Model Name] = "EF")

THEN "Group B"

ELSE [Category]

END

Lastly, if all my Model names beginning with D should fall into Group A, can I put an asterisk in place of the 'C' as such:

IF ([Category] = "Null"

AND [Model Name] = "D* ")

THEN "Group A"

ELSE [Category]

END

Nicola

• ###### 1. Re: Creating groups through IF / ELSEIF / AND formula

"Null" is a string, which isn't the same as NULL (what you're seeing on the screen)

Try this :

IF ISNULL([Category]) AND [Model Name] = "DC"

THEN "Group A"

ELSE [Category]

END

Basically you have to use ISNULL to see if [Category] has a NULL value or not.

• ###### 2. Re: Creating groups through IF / ELSEIF / AND formula

Works perfectly Chris, thanks for your help!