+ Reply to Thread
Results 1 to 7 of 7

Change phone number format in power query

  1. #1
    Registered User
    Join Date
    01-30-2022
    Location
    Texas
    MS-Off Ver
    365
    Posts
    62

    Change phone number format in power query

    Hi,

    I need to change the phone number format in the "Phone" column to 999-122-1122.
    In the data, I have (999)122-1212, 9991221212, and 999-122-1122.
    Is there any easy way to do it in power query?

    Thank you

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,064

    Re: Change phone number format in power query

    PowerQuery won't change numbers in a column - it can only produce a copy and format it accordingly, so you might as well use a formula. With your phone numbers in A1 down, this in B1 copied down:

    =--SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"(",""),")",""),"-","")

    Then format column B with the custom format: 000-000-0000

    Alternatively, you could do Find & Replace three times on column A (for (, ) and -), then format column A as above.
    Attached Files Attached Files
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,418

    Re: Change phone number format in power query

    Power Query
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,064

    Re: Change phone number format in power query

    And another slightly shorter PQ solution:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Change phone number format in power query

    my 3 cents

    Please Login or Register  to view this content.
    raw TI
    (999)122-1212 999-122-1212
    9991221212
    999-122-1212
    999-122-1122 999-122-1122

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Change phone number format in power query

    Please try

    PHP Code: 
    let
        Source 
    Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        
    Ans Table.AddColumn(Source"Format"each Number.ToText(Number.From(Text.Select(Text.From([Column1]),{"0".."9"})),"000-000-0000"))
    in
        Ans 

  7. #7
    Registered User
    Join Date
    01-30-2022
    Location
    Texas
    MS-Off Ver
    365
    Posts
    62

    Re: Change phone number format in power query

    Thank you all for the help. Bo_Ry, your code worked perfectly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Table format change using power query
    By knowone840 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 02-15-2021, 02:54 AM
  2. Phone Number - Change Format Pt. 2
    By KBeglan in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-17-2020, 11:07 PM
  3. Phone Number - change format
    By KBeglan in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-17-2020, 09:23 AM
  4. [SOLVED] Change Phone Number With International Dial Code Back To UK Format
    By RedMacLeod in forum Excel General
    Replies: 2
    Last Post: 04-18-2018, 09:06 AM
  5. [SOLVED] Change the phone number format to unique
    By sjpras in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-11-2015, 04:47 AM
  6. Change Phone number format
    By genefalk1 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-26-2014, 10:43 PM
  7. Format change of phone number
    By helpjim in forum Excel General
    Replies: 7
    Last Post: 05-18-2006, 02:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1