Substitute for Excel Function: TEXT(A2,"000000")

porter444

New member
Joined
Sep 8, 2016
Messages
14
Reaction score
0
Points
0
Location
Birmingham, AL
Excel Version(s)
Excel 2016 MSO 64 Bit
I have a workbook that contains bin locations. the location format is 6 digits, but sometimes on export if the leading digit of the location is a zero it gets left out (type becomes number). In the past I dealt with this by adding a column to convert the location to a 6 digit format with TEXT(A2,”000000″).



I’m now trying to leave those old Excel tricks behind. I’m importing the workbook via powerquery and want to handle the formatting issue there. I change the type to TEXT, but then am not sure how approximate the Excel TEXT( function in powerquery.

Sample data attached.
 

Attachments

  • Book1.xlsx
    14.2 KB · Views: 24
Here's how I approached it:
  • Pull the data into Power Query
  • Change the data type of the first column to Text. (Your preview will default to numeric, but around line 478 you have text combinations... you'll get errors later if you skip this step)
  • Rename the first column to Location_old
  • Go to Add Column --> Add Custom Column

And here's the formula for the new column (which I called Location)
Code:
Text.End("000000"&[Location_old],6)

Sample attached.
 

Attachments

  • Solution.xlsx
    26 KB · Views: 25
An alternative approach would be to follow the same steps mentioned by Ken, but use the Text.PadStart function instead.

The function would be:

Code:
Text.PadStart([Location], 6, "0")

Regards,
Orlando
 
Back
Top