Help

Re: Combining two fields with comma when either might be blank

Solved
Jump to Solution
1635 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Albas
4 - Data Explorer
4 - Data Explorer

Trying to get 'Full Name', 'Organization' in my primary field. My problem is that sometimes both 'Full Name' and 'Organization' are filled in, and sometimes it's only one or the other. I tried using the following formula, and it worked when one or the other is filled in, but when both are filled in, it doesn't add the comma and space. I'll attach an image so it's clear what I mean.

 

IF({Full Name}, {Full Name} & 
IF({Organization}, {Organization} & 
IF(({Full Name}+{Organization}),({Full Name} & ", " & {Organization}))))

 

Airtable Glitch.png

 

1 Solution

Accepted Solutions

I guess your {Full Name} formula is something like {First Name} & " " & {Last Name}, so it is never empty.
You can wrap it all into TRIM(   ) and that will solve the problem.
Or you can trim it in the Customer formula,

I think, that should work OK:

 

{Full Name} & IF( AND(TRIM({Full Name}),{Organization}), ", ") & {Organization}

 




See Solution in Thread

7 Replies 7
Sho
11 - Venus
11 - Venus

In Airtable, for example, the formula would look like this

IF(
  OR({Full Name}, {Organization}),
  IF(
    {Full Name},
    {Full Name} & 
    IF(
      {Organization},
      ", " & {Organization}
    ),
    {Organization}
  )
)

 

Hi, 

IF(Field1 + Field2, ....         - doesn't work 
there are two ways to check,
IF(AND(Field1,Field2), 'both not empty')  or
IF(Field1, IF(Field2,'both not empty'))

Regarding your formula, part of it is redundant.
Your desired result is

{Full Name} & ", " & {Organization}

when a field (any or both) is empty, nothing changes for side parts.  But delimiter needs only for 2 values, so

{Full Name} & IF({Full Name},IF({Organization},", ")) & {Organization}

Tried this and while it inserted the comma when both 'Full Name' and 'Organization' were found, it also inserted the comma and a space before the organization when only the 'Organization' was found.

Albas_0-1701622038480.png

 

This, too, like the previous suggestion, inserted the comma when both 'Full Name' and 'Organization' were found—but also inserted the comma and a space before the organization when only the 'Organization' was found.

Albas_0-1701622038480.png

 

Sho
11 - Venus
11 - Venus

If so, the Full Name may contain spaces.
Please check the formula.

I guess your {Full Name} formula is something like {First Name} & " " & {Last Name}, so it is never empty.
You can wrap it all into TRIM(   ) and that will solve the problem.
Or you can trim it in the Customer formula,

I think, that should work OK:

 

{Full Name} & IF( AND(TRIM({Full Name}),{Organization}), ", ") & {Organization}

 




Hey, thanks! That did the trick!