- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Leading zeroes in zip codes
I am trying to use zip codes to make a heat map but when I import the data from excel, the zeroes infront of certain zip codes are removed. I have tried formatting the zip column as text as suggested in other posts. Are there any other work arounds that I could try?
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey @blocke
You can create a calculated column to insert the leading 0's back in. So let's say that you have three zip codes (76342, 08976, and 00323). One has no leading 0's, one has 1, and one has 2. Based on what I'm gathering, when you import them in you are seeing 76342, 8976, 323. You can then create a calculated column to append necessary 0's on front depending on the size of the number like this:
RealZipCode = SWITCH( TRUE(), LEN('Table'[ZipCode]) = 5, 'Table'[ZipCode], LEN('Table'[ZipCode]) = 4, "0" & 'Table'[ZipCode], LEN('Table'[ZipCode]) = 3, "00" & 'Table'[ZipCode] )
You end up with output that looks like:
Hope this helps,
Parker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
None of the solutions worked for me but adding a prefix did.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can also use this:
= Text.PadStart([Zip],5,"0")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
=Text.PadStart([ZipCode], 5, "0")

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know that this was marked as solved, but I also had this issue and fixed it by changing the table column data type definition in Power BI's query editor from int64 to text.
Example: = Table.TransformColumnTypes(Table1_Table,{{"Zip Code", type text}, {"City", type text}, {"County", type text}})

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey @blocke
You can create a calculated column to insert the leading 0's back in. So let's say that you have three zip codes (76342, 08976, and 00323). One has no leading 0's, one has 1, and one has 2. Based on what I'm gathering, when you import them in you are seeing 76342, 8976, 323. You can then create a calculated column to append necessary 0's on front depending on the size of the number like this:
RealZipCode = SWITCH( TRUE(), LEN('Table'[ZipCode]) = 5, 'Table'[ZipCode], LEN('Table'[ZipCode]) = 4, "0" & 'Table'[ZipCode], LEN('Table'[ZipCode]) = 3, "00" & 'Table'[ZipCode] )
You end up with output that looks like:
Hope this helps,
Parker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ZIP = RIGHT("00000" & 'myaddresses'[myzip], 5)

Helpful resources
Join our Fabric User Panel
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Power BI Monthly Update - June 2025
Check out the June 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
03-14-2016 11:59 AM | |||
09-27-2023 03:58 AM | |||
06-05-2022 08:00 PM | |||
05-02-2025 09:52 AM | |||
Anonymous
| 09-07-2017 05:04 AM |
User | Count |
---|---|
58 | |
55 | |
55 | |
37 | |
30 |
User | Count |
---|---|
78 | |
64 | |
45 | |
43 | |
40 |