In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!

Alteryx Designer Desktop Discussions

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

Delete first character of a cell only if it meet a condition

Axis
7 - Meteor

Hello all,

 

I want to delete the first character of the cells of a column only if it meet some exact condition. 

In my specific case, I want to delete the first coma of the rows where there is one. 

 

Example : 

DAN,DEU,FRA,ITA,POL,POR,SLO,SPA
DEU,DUT,FRA,GRE,ITA,SPA
DEU,FRA,ITA
DEU,DUT,FRA,ITA
DUT
DUT
,CZE,DEU,DUT,FIN,FRA,GRE,HUN,ITA,NOR,POL,POR,SLO,SPA,SWE
,DEU,DUT,FIN,FRA,GRE,ITA,POL,SPA
,DEU,DUT,FIN,FRA,GRE,ITA,NOR,POR,SPA,SWE
,CZE,DEU,FRA,ITA,POL,POR,SPA
,DEU,DUT,FRA,GRE,HUN,ITA,NOR,SPA

 

Do you have a simple way to do so? 

 

Thanks for your help!

Best regards,
Axis

5 REPLIES 5
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Axis,

 

There's some very powerful string functions you can use within Alteryx! In this case i've used the TrimLeft() function to remove any leading commas:

 

TrimLeft([Text],',')

 

Input:

JonathanSherman_1-1637055380215.png

 

 

 

Output:

JonathanSherman_0-1637055357361.png

 

I've attached my workflow for you to download if needed!

 

Kind regards,

Jonathan

 

Harrylosborne
8 - Asteroid

Hi @Axis , are you saying you want to delete the first comma if it appears before any of the entries in your data (as with the bottom 5 rows), or to delete the first comma if it ever appears in a row of data?

Axis
7 - Meteor

That's exactly what I was looking for!

Thanks for the quick help,

Have a nice day!

Jonathan-Sherman
15 - Aurora
15 - Aurora

No problem at all, and you!

HomesickSurfer
12 - Quasar

Hi @Axis 

 

Further to @Jonathan-Sherman's solution, try the following just in case the comma may additionally appear at the end of your string values:

This removes it from both front(left)(start) and back(right)(end)

 

Trim([Field1],',')

 

Labels
Top Solution Authors