Zip to Fips SQL Cheat
Though there is option to have domo build a custom fips dataset for your instance and it may seem easy to do a seperate table for joining - it has arisen that sometimes joining does not provide all table rows to be assigned appropirate fips. Sometimes, conversely you are looking for specific counties or to bucket (numeric) fips in a particular way. If either of those are applicable to your use case, hopefully the following sample will help.
In case you need a quick zip to fips code, here is sample for use in SQL using Manhattan zips only.
SELECT *,
CASE
when `Zipcode`='10024' then '36061'
when `Zipcode`='10016' then '36061'
when `Zipcode`='10014' then '36061'
when `Zipcode`='10026' then '36061'
when `Zipcode`='10027' then '36061'
when `Zipcode`='10004' then '36061'
when `Zipcode`='10023' then '36061'
when `Zipcode`='10020' then '36061'
when `Zipcode`='10022' then '36061'
when `Zipcode`='10017' then '36061'
when `Zipcode`='10006' then '36061'
when `Zipcode`='10019' then '36061'
when `Zipcode`='10029' then '36061'
when `Zipcode`='10007' then '36061'
when `Zipcode`='10009' then '36061'
when `Zipcode`='10010' then '36061'
when `Zipcode`='10011' then '36061'
when `Zipcode`='10045' then '36061'
when `Zipcode`='10072' then '36061'
when `Zipcode`='10038' then '36061'
when `Zipcode`='10082' then '36061'
when `Zipcode`='10080' then '36061'
when `Zipcode`='10035' then '36061'
when `Zipcode`='10106' then '36061'
when `Zipcode`='10065' then '36061'
when `Zipcode`='10112' then '36061'
when `Zipcode`='10110' then '36061'
when `Zipcode`='10087' then '36061'
when `Zipcode`='10044' then '36061'
when `Zipcode`='10055' then '36061'
when `Zipcode`='10034' then '36061'
when `Zipcode`='10048' then '36061'
when `Zipcode`='10069' then '36061'
when `Zipcode`='10105' then '36061'
when `Zipcode`='10156' then '36061'
when `Zipcode`='10163' then '36061'
when `Zipcode`='10121' then '36061'
when `Zipcode`='10160' then '36061'
when `Zipcode`='10122' then '36061'
when `Zipcode`='10154' then '36061'
when `Zipcode`='10157' then '36061'
when `Zipcode`='10166' then '36061'
when `Zipcode`='10133' then '36061'
when `Zipcode`='10128' then '36061'
when `Zipcode`='10153' then '36061'
when `Zipcode`='10124' then '36061'
when `Zipcode`='10149' then '36061'
when `Zipcode`='10132' then '36061'
when `Zipcode`='10164' then '36061'
when `Zipcode`='10119' then '36061'
when `Zipcode`='10118' then '36061'
when `Zipcode`='10151' then '36061'
when `Zipcode`='10165' then '36061'
when `Zipcode`='10271' then '36061'
when `Zipcode`='10169' then '36061'
when `Zipcode`='10279' then '36061'
when `Zipcode`='10172' then '36061'
when `Zipcode`='10177' then '36061'
when `Zipcode`='10174' then '36061'
when `Zipcode`='10270' then '36061'
when `Zipcode`='10176' then '36061'
when `Zipcode`='10259' then '36061'
when `Zipcode`='10276' then '36061'
when `Zipcode`='10277' then '36061'
when `Zipcode`='10256' then '36061'
when `Zipcode`='10171' then '36061'
when `Zipcode`='10179' then '36061'
when `Zipcode`='10249' then '36061'
when `Zipcode`='10268' then '36061'
when `Zipcode`='10272' then '36061'
when `Zipcode`='10260' then '36061'
when `Zipcode`='10213' then '36061'
when `Zipcode`='10280' then '36061'
when `Zipcode`='10286' then '36061'
when `Zipcode`='10463' then '36061'
when `Zipcode`='10281' then '36061'
when `Zipcode`='10282' then '36061'
when `Zipcode`='10039' then '36061'
when `Zipcode`='10170' then '36061'
when `Zipcode`='10025' then '36061'
when `Zipcode`='10043' then '36061'
when `Zipcode`='10108' then '36061'
when `Zipcode`='10032' then '36061'
when `Zipcode`='10261' then '36061'
when `Zipcode`='10036' then '36061'
when `Zipcode`='10003' then '36061'
when `Zipcode`='10274' then '36061'
when `Zipcode`='10013' then '36061'
when `Zipcode`='10126' then '36061'
when `Zipcode`='10030' then '36061'
when `Zipcode`='10047' then '36061'
when `Zipcode`='10012' then '36061'
when `Zipcode`='10116' then '36061'
when `Zipcode`='10265' then '36061'
when `Zipcode`='10028' then '36061'
when `Zipcode`='10041' then '36061'
when `Zipcode`='10123' then '36061'
when `Zipcode`='10273' then '36061'
when `Zipcode`='10197' then '36061'
when `Zipcode`='10278' then '36061'
when `Zipcode`='10001' then '36061'
when `Zipcode`='10125' then '36061'
when `Zipcode`='10040' then '36061'
when `Zipcode`='10129' then '36061'
when `Zipcode`='10138' then '36061'
when `Zipcode`='10155' then '36061'
when `Zipcode`='10018' then '36061'
when `Zipcode`='10275' then '36061'
when `Zipcode`='10130' then '36061'
when `Zipcode`='10033' then '36061'
when `Zipcode`='10152' then '36061'
when `Zipcode`='10114' then '36061'
when `Zipcode`='10242' then '36061'
when `Zipcode`='10158' then '36061'
when `Zipcode`='10081' then '36061'
when `Zipcode`='10168' then '36061'
when `Zipcode`='10175' then '36061'
when `Zipcode`='10021' then '36061'
when `Zipcode`='10167' then '36061'
when `Zipcode`='10031' then '36061'
when `Zipcode`='10104' then '36061'
when `Zipcode`='10109' then '36061'
when `Zipcode`='10185' then '36061'
when `Zipcode`='11201' then '36061'
when `Zipcode`='10161' then '36061'
when `Zipcode`='10199' then '36061'
when `Zipcode`='10005' then '36061'
when `Zipcode`='10150' then '36061'
when `Zipcode`='10102' then '36061'
when `Zipcode`='10269' then '36061'
when `Zipcode`='10178' then '36061'
when `Zipcode`='10008' then '36061'
when `Zipcode`='10115' then '36061'
when `Zipcode`='10173' then '36061'
when `Zipcode`='10002' then '36061'
when `Zipcode`='10285' then '36061'
when `Zipcode`='10111' then '36061'
when `Zipcode`='10113' then '36061'
when `Zipcode`='10103' then '36061'
when `Zipcode`='10107' then '36061'
when `Zipcode`='10037' then '36061'
when `Zipcode`='10292' then '36061'
when `Zipcode`='10075' then '36061'
when `Zipcode`='10101' then '36061'
when `Zipcode`='10162' then '36061'
when `Zipcode`='10117' then '36061'
when `Zipcode`='10131' then '36061'
when `Zipcode`='10159' then '36061'
when `Zipcode`='10120' then '36061'
end as Fips
from transform_data_1
Zip to Fip Source: https://data.ny.gov/Government-Finance/New-York-State-ZIP-Codes-County-FIPS-Cross-Referen/juva-r6g2/data
Use excel's downfill function to quickly create your cases (and remove spaces) before pasting into sql.
If your zip code is not formatted in 5 digits you may need to run step before this case:
SELECT *,
LEFT(zipcod, 5) as zipcode
FROM source_table
Comments
-
Great tips, thanks Lauren
0 -
you could do
select *, case when `zipcode` in (......) then '36061' end as fips from transform_data_1
Reduces the number of lines.
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 58 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive