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 last two digits and replace with number from another column

joanq
7 - Meteor

hi all,

can you please help me with this task:

'Replace last digits of XXX with number in YYY column' example:

 

XXX     YYY     New XXX

1250     36       1236

12345   22       12322

 

Can you please help how can I insert such formula in my workflow?

6 REPLIES 6
Ladarthure
14 - Magnetar
14 - Magnetar

Hi @joanq,

 

multiple methods here, but first transform your data in string fields

  • Formulas:
    • use the length function to have the number of digits
    • use a left function to get the first numbers with a number of char equal to lenght - 2
    • add the YYY field to get what you want:
    • left([XXX],Length([XXX])-2)+[YYY]
  • RegEx
    • replace the last group of the regex (which will be 2 digits) by nothing and combine it with YYY
    • REGEX_Replace([XXX], '(.+)(\d{2})','$1')+[YYY]

Hope it helps!

sparksun
11 - Bolide

Here is my try FYR.

messi007
15 - Aurora
15 - Aurora

@joanq,

 

Please see below:

messi007_0-1611047783031.png

Attached the workflow,

 

Hope that helps!

Regards

joanq
7 - Meteor

thank you very much! it worked.

Exacto99
5 - Atom

How can I replace the first two digits of a string of numbers with two digits from another column? @Ladarthure @messi007

20000000226260000002
20000904926260009049
20001081526260010815
messi007
15 - Aurora
15 - Aurora

@Exacto99,

 

You can do that using a formula tool :

 

Community_20240106.png

 

Attached the workflow,

Regards

Labels