Working with Zip codes in Excel


Working with zip codes in Excel

I got a question recently about how to match ZIP codes to counties, and it occurred to me this could be helpful to others! It's really easy.

You can do this trick with any of the later versions of Excel. 

Step 1. Make sure your zip codes are numbers (not text) in Excel
Step 2. Highlight zip codes and select Data>Data Types>Geography
That's it! Now you will get a little "insert data" icon next to the zip codes that you can use to add other location data, like county, state, city, etc. It will show up in its own column.

animation of showing counties for each zip

Then you can map it. Oh yes I said map it!! In Excel!! I know!!

But first, you probably want to pivot so that the map shades according to frequency of zip/county. Select all the county names and select Insert>Pivot Table. Put counties as your rows and values.

animation of pivoting counties

To map this pivot data, you'll need to copy/paste out of the pivot format. Here I just stuck the data back on the first sheet. Then made it Geography data type again--that's an important step! (it lost that during pivoting). Then Insert>Map>Fill Map. 

(note: you can do map at the Zip code level but your polygons will be so small that the boundaries will pretty much obscure the whole map)

animation of making a county map in excel

See, it's easy right, once you know the steps! Let me know if you try it and what you think of this cool feature of Excel!

Comments

  1. This is SO great to know about. You wouldn't believe the data gymnastics I've gone through when trying to do things like this with other tools!

    ReplyDelete
  2. Awesome information. Thanks so much!

    ReplyDelete
  3. Which Excel versions have the geography data type? I don't see it in the 2016 version on my Extension laptop.

    ReplyDelete
    Replies
    1. Excel for Microsoft 365. You can upgrade https://it.umn.edu/services-technologies/resources/office

      Delete
  4. Excellent, such a great tip to know!

    ReplyDelete
  5. Just be weary that the shape of Minnesota is off- your stakeholders in Cook county aren't going to like this. We often translate mapping data into other mapping software or use the Extension maps and manually fill in colors.

    ReplyDelete
    Replies
    1. Cook county is definitely looking a little squashed there! lol!

      Delete
  6. I think this trick is more cumbersome now that Word is using Bing data to pull information. It seems like you have to move from zip code => city => county. I've tried this with some zip codes and it gave erroneous county results (compared to previous versions).

    ReplyDelete
    Replies
    1. I am having good luck with the new process in general--which just involves converting to city first, then converting to county from that. It does not work well for St. Paul/Minneapolis, due to the city name matching to more than one county. I hope Excel will add back the "admin division 2"!

      Delete

Post a Comment