Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

replace certain positions of a string

Nandy
8 - Asteroid

i have a string concatenated of length 20 , all i need is to replace saying 10th position to 12th as blank irrespective of any value in those positions.

 

is there a way to do this?

 

2MAIII0123X4TGHIJKLM

 

2MAIII0123X GHIJKLM
7 REPLIES 7
yalmar_m
11 - Bolide

Hi @Nandy,

 

The most easy way to do it is to use the formula tool and use the following formula.

Replace([Field1],
Left(Right([Field1], Length([Field1])-10),3),' ')

 

Where field1 is the field containing your string.


Best,

Yalmar

 

CharlieS
17 - Castor
17 - Castor

Nice solution, @yalmar_m

 

Here's another way to approach this: 

left([String],1+[Start])+" "+right([String],length([String])-[Stop]-1)

 

[Start]==10 and [Stop]==12. The "+1" and "-1" were added to to produce the results based on your specifications in your post.

Nandy
8 - Asteroid
Thanks @yalmar
Will try definitely
Nandy
8 - Asteroid
Thanks Charlie.

I find it tough in understanding this since am beginner would be glad if you can explain if possible.
CharlieS
17 - Castor
17 - Castor

Here's the breakdown. I'm basically building the string using pieces of the original. I'll evaluate each part step by step:

 

left(       will return the characters on the left for the length specified

left([String],1+[Start])  

left(2MAIII0123X4TGHIJKLM,1+10)

left(2MAIII0123X4TGHIJKLM,11)

=2MAIII0123X

 

+" "+

=adds a space

 

right(       will return the characters on the right for the length specified

right([String],length([String])-[Stop]-1)

right(2MAIII0123X4TGHIJKLM,length(2MAIII0123X4TGHIJKLM)-12-1)

right(2MAIII0123X4TGHIJKLM,20-12-1)

right(2MAIII0123X4TGHIJKLM,7)

=GHIJKLM

 

So all together:

"2MAIII0123X"+" "+"GHIJKLM" yields "2MAIII0123X GHIJKLM"

yalmar_m
11 - Bolide

@Nandy,

 

Did it work out?


Best,

Yalmar

Nandy
8 - Asteroid

@Yalmar

 

Yes it worked out .

 

thanks for your support.

Nandy

Labels