We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

phone numbers: change the country code with +[country code]

msantoso
8 - Asteroid

Hi everyone, 

 

I have phone numbers entered as 49123456789, where "49" is the country code

I'd like to change the format to +49 123456789

 

I tried this

if StartWith[Phone], "49"

then replace[phone], "49", "+49 "

 

this formula changes also any '49' string within the phone number, which is not what I aim to. 

 

how can I say that I want to change only the first occurrence? 

 

thank you

ms

2 REPLIES 2
BenMoss
ACE Emeritus
ACE Emeritus

If left([Field],2) = '49' Then '+49 ' + right([field],length([field])-2) Else [field] endif

 

Something a bit more dynamic would be quite simple...

 

'+'+left([field],2)+' '+right([field],length([field])-2)

 

Though you may want to build out some logic to check if the phone number does indeed start with a country code.

 

Ben

msantoso
8 - Asteroid

thank you BenMoss! 

 

Yes, I'll keep the IF, since I have phone numbers without country code

Labels
Top Solution Authors