[SOLVED] Replacing the international code of a telephone number

Kate_Strydom
Kate_Strydom New Altair Community Member
edited November 5 in Community Q&A
Hi,

I am battling to replace the first two digits (international code) of a mobile phone number, for example, 27766270940 without RM replacing the other set of 27 within the number.
I need the mobile number to become 0766270940.

Can anyone assist me?

Thanks
Kate
Tagged:

Answers

  • sgenzer
    sgenzer
    Altair Employee
    If it were me, I would make it a nominal attribute (if not already) and generate a new attribute where the function would be concat("0",suffix(att1,9))

    Scott
  • Kate_Strydom
    Kate_Strydom New Altair Community Member
    Thanks Scott. Your approach works well.  :)

    My attribute is already nominal. I was trying to use a start and replace function but they were not working very well.

    Now I have some mobile numbers that need to be excluded or replaced as missing, once I have applied your approach. Basically I need to exclude any number with 00 or 01.

    This expression  if(prefix(mobile_number, "00"), " ", if( prefix(mobile_number, "01"), " ", mobile_number) is giving me errors.

    Any suggestions?

    Kate
  • MartinLiebig
    MartinLiebig
    Altair Employee
    Hi Kate,

    i think you simply forgot a paranthesis. This should work:

    if(prefix(mobile_number, "00"), " ", if( prefix(mobile_number, "01"), " ", mobile_number))
    you can by the way split this into two parts in Generate Attributes. Than it is a bit more readable.

    Cheers,

    Martin
  • Kate_Strydom
    Kate_Strydom New Altair Community Member
    Hi Martin,

    My error when typing out the function. Sorry :o.

    When I was driving home last night I realised that the prefix function is the problem. I cannot use a prefix to identify the 00 and 01 as this function will keep the first two digits. I want it to identify the first two digits and then exclude the ones that are not valid.

    Got it. Now Scott's approach works perfectly for me.

    if(starts(mobile_number, "00") || starts(mobile_number, "01") || starts(mobile_number, "02") || starts(mobile_number, "04"), " ", mobile_number)
    Thanks Scott and Martin for your contribution; :D . It was a great help when you are all alone behind a pc with no other RM person to bounce ideas off.

    Regards,
    Kate
  • MartinLiebig
    MartinLiebig
    Altair Employee
    No problem! it is always great to see, that people use our product!