“I have a long number in the SharePoint list, how can I format it as a phone number in PowerApps app, to separate the numbers?”
One of the befits of using PowerApps is that you’re in control of what the users see. How does the app look, what options the users have, and how they see the data. That means also the possibility to format it in the most user friendly way. I already wrote an article on formatting numbers as a currency, now it’s about a more personal information – the phone numbers.
When you show phone numbers, you don’t want to show a single long number. Users might want to rewrite the number on their phones, which is much easier if there’re some separators.
Even phone number is just a number
Even though it might not feel like it, phone number is still just a number. If you remove the plus or 00 from the country code part, it’s a number like any other. And since it’s a number, you can easily format it!
For example, let’s take an imaginary Czech phone number.
+420777123345
Firstly, remove the + representing country code.
Substitute(txt_phoneNumber_string.Text, "+", "")
Once the + is gone, it’s a number!
Convert it into a number with Value(…) function…
Value(Substitute(txt_phoneNumber_string.Text, "+", ""))
…and format it as a number using Text(…) function. In this case it’s much easier to format the number than with the currency as you know the number of digits.
Text(
Value(
Substitute(
txt_phoneNumber_string.Text,
"+",
""
)
),
"### ### ### ###"
)
The # character always represents a number, anything else are the separators. To format e.g. US number it might include brackets and dashes (the removal of + is optional in the example below).
Text(
Value(
Substitute(
txt_phoneNumber_string.Text,
"+",
""
)
),
"(###) ###-####"
)
Feel free to add the + you removed at the beginning back before the formatted number.
Summary
When showing a phone number in PowerApps, you should remember that it’s just a number that you can format. It might contain some special characters, country code, some separators… But once you remove them and turn it into a simple number, you can format it. Convert it back into a Text(…) and format it using # for numbers and other characters as separators.
1 thought on “Format number as a phone number in PowerApps”