Expand my Community achievements bar.

Displaying " , " between text from a CONCAT formula

Avatar

Level 3

Hi All,

I've created a concat formula that pulls in multiple typeahead fields.  What I'm trying to figure out is how to display a comma if more than one typeahead field has been filled out, but not to display a comma if there's only one field being populated.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

7 Replies

Avatar

Level 2

Hi OmahaOmaha, 

 

Please share your calculated formula. This will make it easier to troubleshoot. 

 

Thanks - 

Teale

Avatar

Level 3

sure thing:

 

CONCAT({DE:Comp:name},{DE:Lab:name},{DE:VFX 2:name},{DE:VFX:name},{DE:Post:name})

Avatar

Level 4

Hi @OmahaOmaha 

 

The syntax for the CONCAT expression should be 

CONCAT({DE:Comp:name},",",{DE:Lab:name},",",{DE:VFX 2:name},",",{DE:VFX:name},",",{DE:Post:name})

 

Hope this helps!

Please try this out and let us know if this is working.

Avatar

Level 3

the only problem with this is that I don't want it to display commas if only one field was selected. For instance with this formula if the first two fields weren't edited it would display as:  ,,VFX:name,Post:name.  I would want it to display as: VFX:name,Post:name.   essentially skipping the first two and not adding commas b/c nothing was selected.

Avatar

Level 2

Give this a try....

 

IF(!ISBLANK({DE:Comp:name}&&IF(!ISBLANK({DE:Lab:name}),CONCAT({DE:Comp:name}," - ",{DE:Lab:name}),IF(!ISBLANK({DE:Comp:name}&&IF(!ISBLANK({DE:Lab:name}&&IF(!ISBLANK({DE:VFX:name}),CONCAT({DE:Comp:name}," - ",{DE:Lab:name}, "- ", {DE:VFX:name}),IF(!ISBLANK({DE:Comp:name}&&IF(!ISBLANK({DE:Lab:name}&&IF(!ISBLANK({DE:VFX:name}&&IF(!ISBLANK({DE:Post:name}),CONCAT({DE:Comp:name}," - ",{DE:Lab:name}, "- ", {DE:VFX:name}," - ", {DE:Post:name}), ""))))))))))

Avatar

Community Advisor

In my mind, you need to account for all possible combinations of blank vs not-blank. As an example, consider 3 fields:

* all 3 could be blank

* all 3 could be filled out

* any one of the fields could be filled out

* any 2 fields could be filled out

 

So (again, my opinion) a calculation would need to consider all of these combinations. For 5 fields, there are (I guess?) 32 combinations -- pretty menial labor, so -- have you considered asking chatGPT?

 

I gave it a 2 field combination

i.e. I made code for if the first field was blank, if the second field was blank, if either were filled out, and if both were filled out -- 5 combinations = IF(ISBLANK({DE:field1}),(IF(ISBLANK({DE:field2}),"",{DE:field2}),CONCAT({DE:field1},IF(ISBLANK({DE:field2}),"",",",{DE:field2})

 
And it cleaned up my code and expanded it to 5 fields and the resulting code might not even be correct, but what I'm getting at is that it is going to be complicated to picture, fairly menial to create (without AI), require thorough testing, and it will be really difficult to maintain.
 
IF(
ISBLANK({DE:field1}),
IF(
ISBLANK({DE:field2}),
IF(
ISBLANK({DE:field3}),
IF(
ISBLANK({DE:field4}),
IF(
ISBLANK({DE:field5}),
"",
{DE:field5}
),
CONCAT({DE:field3}, IF(ISBLANK({DE:field5}), "", CONCAT(",", {DE:field5})))
),
CONCAT({DE:field4}, IF(ISBLANK({DE:field5}), "", CONCAT(",", {DE:field5})))
),
CONCAT(
{DE:field2},
IF(ISBLANK({DE:field3}), "", CONCAT(",", {DE:field3})),
IF(ISBLANK({DE:field4}), "", CONCAT(",", {DE:field4})),
IF(ISBLANK({DE:field5}), "", CONCAT(",", {DE:field5}))
)
),
CONCAT(
{DE:field1},
IF(ISBLANK({DE:field2}), "", CONCAT(",", {DE:field2})),
IF(ISBLANK({DE:field3}), "", CONCAT(",", {DE:field3})),
IF(ISBLANK({DE:field4}), "", CONCAT(",", {DE:field4})),
IF(ISBLANK({DE:field5}), "", CONCAT(",", {DE:field5}))
)
)
 
 
Breakdown of the AI logic:
Outer Logic: The outer IF checks if {DE:field1} is blank.
Nested Logic: Each nested IF checks the subsequent fields, building up the concatenation step by step. If a field is not blank, it’s added to the final output with a preceding comma if needed.
Concatenation: For each field, we check if it is blank before concatenating it to ensure proper formatting.
 
 

Avatar

Level 3

Whoa...  Probably going to need to think of another way to do this.  In actuality I'm dealing with 12 typeahead fields, so I'm going need to think of another way of doing this.  Thanks everyone for your input, greatly appreciated.