Displaying " , " between text from a CONCAT formula | Community
Skip to main content
Level 4
October 29, 2024
Question

Displaying " , " between text from a CONCAT formula

  • October 29, 2024
  • 3 replies
  • 1060 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Level 2
October 29, 2024

Hi OmahaOmaha, 

 

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

 

Thanks - 

Teale

Level 4
October 29, 2024

sure thing:

 

CONCAT({DE:Comp:name},{DE:Lab:name},{DE:VFX 2:name},{DE:VFX:name},{DE:Post:name})
Srinija_N
Level 7
October 30, 2024

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.

Level 4
October 30, 2024

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.

skyehansen
Community Advisor and Adobe Champion
October 30, 2024

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.
 
 
Level 4
October 30, 2024

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.