Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

manipulate phone number tMap

Hello,
how it´s possible to add the international prefix to a national phone number?
I have the following number 0775188060 and want +49775188060.
Greetings
Labels (2)
7 Replies
Anonymous
Not applicable
Author

Hi
Is there any other records indicates what's the international prefix should be added to number?
Best regards
Shong
Anonymous
Not applicable
Author

Hello,
I only import one country so all prefixes are same.
It´s not a mixed import, I import country by country so I only need to know how to replace the first zero with +49
I don´t have a field with the country prefix inside so I can not combinate two fields.
Greetings
Anonymous
Not applicable
Author

Hi Loki555,
If there's good data quality on your source phone number, you can use a tMap to transform it using the following expression, given it is in String format :
"+49"+StringHandling.RIGHT(row1.phoneNumber,9)
Regards,
Anonymous
Not applicable
Author

The phone number quality is good but the numbers are sometimes longer sometimes shorter.
Can it be done with tReplace?
Thank you very much.
Anonymous
Not applicable
Author

You're right ! You can do it with a tReplace, but you have to make sure that the phone numbers begin with a zero (by filtering with a tMap before), otherwise the prefix won't be concatenated.
See enclosed screenshot, with a simple regex that replace the 0 if it is the first character of the string.
Another way to do that, a little bit more obfuscated, but quicker !
"+49"+source.phoneNumber.substring(1,source.phoneNumber.length())
It replaces the first character of the string with "+49" in all cases, but without making sure it was a 0.
The key is to make sure you have good data quality on your source data !
Anonymous
Not applicable
Author

It worked a while but now I get an error:
connecting to socket on port 3733
connected
Exception in component tMap_1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
I don´t understand why because I don´t change anythig. Unknown Source ... I deleted the expression
"+49"+Kundenadressen.AQAYNA.substring(1,Kundenadressen.AQAYNA.length())
and rewrite it, the source field is linked emediatly but when I restart I get the same error.
When I delete the expression I get no error.
Greetings
Peter
Anonymous
Not applicable
Author

Beware of null/empty strings !
For this expression I gave you, I assume that the column containing the phone number is properly filled with consistent data (I mean correct length, no null values, no empty strings, etc...).
If not, filter it upstream before applying this expression / correctly manage inconsistent data, otherwise you'll get NullPointerExceptions, or ArrayIndexOutOfBoundsExceptions when trying to substring.