• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Formatting numeric string to SSN (000-00-0000)|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Formatting numeric string to SSN (000-00-0000)|Power Query|Excel Forum|My Online Training Hub

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryFormatting numeric string to SSN (0…
sp_PrintTopic sp_TopicIcon
Formatting numeric string to SSN (000-00-0000)
Avatar
Pam Simpson
Oklahoma
Member
Members

Dashboards

Power Pivot
Level 0
Forum Posts: 20
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
1
May 22, 2020 - 7:55 am
sp_Permalink sp_Print

I have a file where the SSN is missing the dashes and the leading zeros.  If I create a new column with power query, what is the correct formula to format the numbers to the 000-00-0000 format?

Examples:

I need 1234567 to become 001-23-4567

12345678 to become 012-34-5678

123476789 to become 123-45-6789

Thank you for your assistance.

sp_AnswersTopicSeeAnswer See Answer
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4354
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
May 22, 2020 - 9:45 pm
sp_Permalink sp_Print

Hi Pam,

Power Query is not the place for formatting. This should be done once you load the data to Excel. You can use a custom number format:

000-00-0000

Hope that clarifies things.

Mynda

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
3
May 22, 2020 - 10:19 pm
sp_Permalink sp_Print

If you need the formula in excel to make it text you can use

=LEFT(REPT("0",9-LEN(B2))&B2,3)&"-"&MID(B2,LEN(B2)-5,2)&"-"&RIGHT(B2,4)

Purfleet

Avatar
Pam Simpson
Oklahoma
Member
Members

Dashboards

Power Pivot
Level 0
Forum Posts: 20
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
4
May 27, 2020 - 8:01 am
sp_Permalink sp_Print

Hi Mynda and Purfleet,

Thank you for your responses.  The SSN is the primary key between two files I am joining through Power Query. (One is already formatted, the other is not.)  I was hoping I could reformat this within the query so that the person using the tool wouldn't have to do any formatting themselves.

So, is it just not possible in Power Query?  I attempted something similar to what Purfleet posted, but it didn't work.  I know the Power Query language isn't the same as a regular Excel formula.

Again, thank you for your help. 🙂

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4354
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
5
May 27, 2020 - 9:34 am
sp_Permalink sp_Print

Hi Pam,

If you want the field to remain a number, then you can't format it in Power Query. If you're happy to convert it to text then you can use Pad.Start to get the correct number of characters, then split the text and insert the hyphens. See file attached.

Mynda

sp_AnswersTopicAnswer
Answers Post
Avatar
Pam Simpson
Oklahoma
Member
Members

Dashboards

Power Pivot
Level 0
Forum Posts: 20
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
6
May 28, 2020 - 2:44 am
sp_Permalink sp_Print

Thank you Mynda!!! That is perfect!

I pray all is well with you and yours in your part of the world!

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 170
Currently Online: Bouskila stephanie, Brenda Krol, James Hwang
Guest(s) 46
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1431
Anders Sehlstedt: 848
Velouria: 574
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 213
A.Maurizio: 202
Aye Mu: 201
Jessica Stewart: 185
Newest Members:
David Collins
Andras Marsi
Orimoloye Funsho
YUSUF IMAM KAGARA
PRADEEP PRADHAN
Vicky Otosnika
Abhishek Singh
Kevin Sojourner
Kara Weiss
And Woox
Forum Stats:
Groups: 3
Forums: 24
Topics: 6047
Posts: 26544

 

Member Stats:
Guest Posters: 49
Members: 31497
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Riny van Eekelen
© Simple:Press —sp_Information
  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
 
  • About My Online Training Hub
  • Contact
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Copyright © 2023 · My Online Training Hub · All Rights Reserved

Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.

Download A Free Copy of 100 Excel Tips & Tricks

excel tips and tricks ebook

We respect your privacy. We won’t spam you.

x