Delete first character of a cell only if it meet a condition
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Solved! Go to Solution.
- Labels:
- Input
- Optimization
- Transformation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
Output:
I've attached my workflow for you to download if needed!
Kind regards,
Jonathan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
That's exactly what I was looking for!
Thanks for the quick help,
Have a nice day!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
No problem at all, and you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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],',')
