We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
fireworks

How to add commas when combining to columns?

richleeb2
8 - Asteroid

In the formula tool, I am using [column 1] + [column 2] but there is a space in between in the output column.  How do I separate with comma?

7 REPLIES 7
Qiu
21 - Polaris
21 - Polaris

@richleeb2 
I am wondering where the space comes from.
If you want to add commma, you can do like this.

[column 1] + ','+ [column 2]
binuacs
21 - Polaris

@richleeb2 use the Trim() function to remove the leading/trailing spaces

binuacs_0-1660863404658.png

 

richleeb2
8 - Asteroid

If column 1 is blank, then the output starts with a comma. 

 

",[column 2]"

 

How do I skip the comma if there is no value?  FYI I have 3 columns of values. 

Qiu
21 - Polaris
21 - Polaris

@richleeb2 
maybe like this 

If isempty([column 1]) then [colum 2] else 
[column 1] + "," + [column 2] 
endif


Some sample data would be good. 

richleeb2
8 - Asteroid

I have 3 columns I need to pull from to a 4th output column, separated by commas.  Some fields could be blank

 

Column 1Column 2Column 3Output
horse pighorse, pig
birdfish bird, fish
catsnakedogcat, snake, dog
Qiu
21 - Polaris
21 - Polaris

@richleeb2 
Data is always better 😁

We can use the Summarize tool instead of lengthy formula, which is also dynamic

0819-richleeb2.PNG

richleeb2
8 - Asteroid

Thanks, I was able to use this formula and it worked

 

Trim(Replace(Trim([Column 1]," ") + ', ' + Trim([Column 2]," ") + ', ' +Trim([Column 3]," "), ", ,", ", "),", ")

Labels
Top Solution Authors