Alteryx Designer Desktop Discussions

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

Take the first and the last character to create key

fomenter
8 - Asteroid

 

Hi. I'm looking for a function which can create key for may data- Taking the first charater, taking the last character plus the lenght of the string.

 

Example

 

Data Field            Key

Data Guy--->        DY7

Subarbun--->       SN8

SA DOR DON--->SN8

 

In short

A)if there is only a single word (Subarubun), take the first character then take the last character measure the lenght then concatenate them= SN8

B)if there are two strings of text (Data Guy), take the first character of the first string(Data), then take the last character of the last string (Guy), measure the lenght then concatenate them=DY7 (since data guy is 7 character without space)

 

Thanks

 

7 REPLIES 7
Federica_FF
11 - Bolide

HI,

 

you can try with a formula tool:

 

Key = (type string)

LEFT([Data Field], 1)

+

RIGHT([Data Field], 1)

+

ToString(LENGTH(Replacechar([Data Field], " ", ""))

fomenter
8 - Asteroid

I used the formula function and used it exactly like this, but not working properly or I'm doing something really silly. Thank you for your help

 

LEFT([DSG], 1)+RIGHT([DSG], 1)+ToString(LENGTH(Replacechar([DSG], " ", ""))

 

 

 

JohnJPS
15 - Aurora

Try Replace rather than ReplaceChar

fomenter
8 - Asteroid

I already tried that option and it says malformed function call

JohnJPS
15 - Aurora

Add one more closing parenthesis at the end of it all as well.  :-)

RodL
Alteryx Alumni (Retired)

Missing a 3rd ")" on the end...

fomenter
8 - Asteroid

Thanks:)

Labels