Free Trial

Alteryx Designer Desktop Discussions

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

How to remove comma at the end of a concatenated string?

richleeb2
8 - Asteroid

I have the following fields with emails separated by a comma.  Some (not all) of them have a comma at the end.  How do I get rid of that using formula tool?

john@test.com,kate@test.com,jill@test.com,
kelly@test.com,
mike@test.com

 

7 REPLIES 7
acarter881
12 - Quasar

Here's one solution (see attached workflow). Writing a formula to check if the last character is a comma, then taking all of the characters except the last one (i.e., the comma).

 

gautiergodard
13 - Pulsar

You could use this formula:

 

if EndsWith([YourField], ",") then trimright([YourField],",")
else [YourField]
endif
Garabujo7
Alteryx
Alteryx

Hello @richleeb2 , you may use the formula Replace([Field1],","," ")

But I think is better use the text-to-columns, splitting to rows.

 

 

Garabujo7_0-1665764058214.png

 

 

Gabriel

DataNath
17 - Castor
17 - Castor

No need for the if statements - TrimRight() will just ignore records without a trailing comma so you can just use:

 

TrimRight([Input],',')

 

DataNath_0-1665764155097.png

 

(Obviously replace [Input] with your own field name).

MarqueeCrew
20 - Arcturus
20 - Arcturus

@DataNath 

 

That's an answer that I can applaud,

 

 

m

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
richleeb2
8 - Asteroid

Thank you this was simple and worked!

Matthew
11 - Bolide

Here's another option that uses regex

 

 

REGEX_Replace([Field1], '(.*),$', '$1')

 

 

 

Matthew_0-1665768862777.png

 

Labels
Top Solution Authors