# Row level formula - Syntax error. Extra IF

I'm looking to group company segments by using a Country lookup. I have a string that looks up a specific country (i.e. DE) and then a CONTAINS function which is looking up more than one Country (GB or IE). The DE formula works fine on its own, so does the GB/IE formula but when grouped together, I get an EXTRA IF error. Can someone help?

``````IF(
CONTAINS('GB|IE', COUNTRY),
IF(
EMPLOYEES >= 750,
'Enterprise',
IF(
EMPLOYEES >= 201,
'MM',
IF(
EMPLOYEES >= 80,
'GRB',
IF(
EMPLOYEES >= 20,
'SB',
'ESB'
)
)
)
),
NULL
)
IF(
COUNTRY = 'DE',
IF(
EMPLOYEES >= 1000,
'Enterprise',
IF(
EMPLOYEES >= 201,
'MM',
IF(
EMPLOYEES >= 46,
'GRB',
IF(
EMPLOYEES >= 11,
'SB',
'ESB'
)
)
)
),
NULL
)
``````
• As a general tip, the first thing that you should do when running into issues with formulas is to format them according to best practice as I have done for you here. In short... put each function onto its own line, and indent an extra level every time you see an open parenthesis. Doing so makes it a lot easier to spot subtle errors (like missing commas and extra/missing parenthesis). Commented Aug 15, 2023 at 1:35

You are missing a comma after

``````IF(EMPLOYEES >= 20,'SB','ESB')))), NULL )
``````

You usually can't just butt two formulas end-to-end and have it work.
The

``````IF(...)
IF(...)
``````

construction is not valid syntax. Formulas need to end up providing a single value in the end, and each of your top-level `IF()` functions provide their own value. So the `IF(COUNTRY = 'DE', ...)` is the "extra IF" the error is complaining about.

In some situations, you could use an operator to take those two results and combine them into a single result, e.g.

``````/* Both IF()s return a single integer */
/* We use addition to take those two intermediate results, and */
/*   combine them into the final, single result */
IF(COUNTRY = 'DE', 1, 0) + IF(CONTAINS('DE|IE'), 2, 0)
``````

In your case, what you want to do is to nest your second `IF()` into the "expression if false" part of the first `IF()`. After all, you don't want to return null unless the Country is neither 'GB', nor 'IE', nor 'DE'. The Country being neither 'GB' or 'IE' is not sufficient for you to give `null` as the result.

``````/* You only want a single top-level IF() */
IF(
CONTAINS('GB|IE', COUNTRY),
/* begin value/expression when true */
IF(
EMPLOYEES >= 750,
/* and I'm not typing out the rest */
),
/* end value/expression when true */

/* begin value/expression when false */
/* Instead of returning null, you need to further check to see if */
/*   the Country is DE */
IF(
COUNTRY = 'DE',
/* not gonna type out the rest of this either */
)
/* end value/expression when false */
)
``````