Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
basel144
New Member

Create single column for zip codes

hi,

i have data like this and want to create one column for all zip codes.  I think I can split the codes into seperate columns but after that I'm stuck.

basel144_0-1763361157328.png

 

thank you

2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @basel144 

 

Download example PBIX with data shown below

 

First, right click on the column header and select Split Column -> By delimiter

 

PhilipTreacy_5-1763364192743.png

 

 

Choose comma as the delimiter and Split At each occurrence

 

PhilipTreacy_1-1763364002996.png

 

Which gives you this

 

PhilipTreacy_6-1763364222078.png

 

 

Right click on the column header of the first column, and click on Unpivot Other Columns

 

PhilipTreacy_7-1763364248893.png

 

PhilipTreacy_8-1763364272609.png

 

Then tidy up by deleting the Attribute column and renaming the other columns

 

PhilipTreacy_9-1763364310266.png

 

Regards

 

Phil

 

 

 

 

 

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

danextian
Super User
Super User

Hi @basel144 

Splitting the Address column by comma into several columns is a safe method if you don't expect more zip codes in the future than what you currently have  for each location. For future-proofing, I would use Text.Split after extracting the zip codes from the address.

danextian_0-1763374902607.png

danextian_1-1763374956617.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Jcy9DsIgGIXhWzHM3wC0/I0a4+Rk3AgDIqlNDRhAr1/4ujzDe5JjLTmm8MrFLxGMEXRGOXFgycWv5eHTVntT1KBsyPb9/g01J9BCMYrhurb2jodbDhsozvvZUKBqyNh+XGJNGczUE4ZzTL9YQFPOzHAymE9lfS7xk0sDKiWV6IwKVBPn/g==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Address = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Address", type text}}),
    #"Inserted Text After Delimiter" = Table.AddColumn(#"Changed Type", "Zip", each Text.AfterDelimiter([Address], ","), type text),
    #"Added Custom" = Table.AddColumn(#"Inserted Text After Delimiter", "Split Zip", each Text.Split([Zip], ",")),
    #"Split Zip" = Table.ExpandListColumn(#"Added Custom", "Split Zip"),
    #"Removed Columns" = Table.RemoveColumns(#"Split Zip",{"Zip"}),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Removed Columns", {{"Address", each Text.BeforeDelimiter(_, ","), type text}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Extracted Text Before Delimiter",{{"Split Zip", type text}})
in
    #"Changed Type1"




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @basel144 

Splitting the Address column by comma into several columns is a safe method if you don't expect more zip codes in the future than what you currently have  for each location. For future-proofing, I would use Text.Split after extracting the zip codes from the address.

danextian_0-1763374902607.png

danextian_1-1763374956617.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Jcy9DsIgGIXhWzHM3wC0/I0a4+Rk3AgDIqlNDRhAr1/4ujzDe5JjLTmm8MrFLxGMEXRGOXFgycWv5eHTVntT1KBsyPb9/g01J9BCMYrhurb2jodbDhsozvvZUKBqyNh+XGJNGczUE4ZzTL9YQFPOzHAymE9lfS7xk0sDKiWV6IwKVBPn/g==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Address = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Address", type text}}),
    #"Inserted Text After Delimiter" = Table.AddColumn(#"Changed Type", "Zip", each Text.AfterDelimiter([Address], ","), type text),
    #"Added Custom" = Table.AddColumn(#"Inserted Text After Delimiter", "Split Zip", each Text.Split([Zip], ",")),
    #"Split Zip" = Table.ExpandListColumn(#"Added Custom", "Split Zip"),
    #"Removed Columns" = Table.RemoveColumns(#"Split Zip",{"Zip"}),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Removed Columns", {{"Address", each Text.BeforeDelimiter(_, ","), type text}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Extracted Text Before Delimiter",{{"Split Zip", type text}})
in
    #"Changed Type1"




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
PhilipTreacy
Super User
Super User

Hi @basel144 

 

Download example PBIX with data shown below

 

First, right click on the column header and select Split Column -> By delimiter

 

PhilipTreacy_5-1763364192743.png

 

 

Choose comma as the delimiter and Split At each occurrence

 

PhilipTreacy_1-1763364002996.png

 

Which gives you this

 

PhilipTreacy_6-1763364222078.png

 

 

Right click on the column header of the first column, and click on Unpivot Other Columns

 

PhilipTreacy_7-1763364248893.png

 

PhilipTreacy_8-1763364272609.png

 

Then tidy up by deleting the Attribute column and renaming the other columns

 

PhilipTreacy_9-1763364310266.png

 

Regards

 

Phil

 

 

 

 

 

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.