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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
khalidmadih
Frequent Visitor

How to convert State name to State Abbreviation

Using a power BI script for creating a calculated column, how can we convert a State Name Table into a State Abbreviation?

3 REPLIES 3
chrisu
Responsive Resident
Responsive Resident

State Abbreivation  SWITCH (
    [State Name],
    "Alaska""AK",
    "Alabama""AL",
    "Arkansas""AR",
    "Arizona""AZ",
    "California""CA",
    "Colorado""CO",
    "Connecticut""CT",
    "Delaware""DE",
    "Florida""FL",
    "Georgia""GA",
    "Hawaii""HI",
    "Iowa""IA",
    "Idaho""ID",
    "Illinois""IL",
    "Indiana""IN",
    "Kansas""KS",
    "Kentucky""KY",
    "Louisiana""LA",
    "Massachusetts""MA",
    "Maryland""MD",
    "Maine""ME",
    "Michigan""MI",
    "Minnesota""MN",
    "Missouri""MO",
    "Mississippi""MS",
    "Montana""MT",
    "North Carolina""NC",
    "North Dakota""ND",
    "Nebraska""NE",
    "New Hampshire""NH",
    "New Jersey""NJ",
    "New Mexico""NM",
    "Nevada""NV",
    "New York""NY",
    "Ohio""OH",
    "Oklahoma""OK",
    "Oregon""OR",
    "Pennsylvania""PA",
    "Rhode Island""RI",
    "South Carolina""SC",
    "South Dakota""SD",
    "Tennessee""TN",
    "Texas""TX",
    "Utah""UT",
    "Virginia""VA",
    "Vermont""VT",
    "Washington""WA",
    "Wisconsin""WI",
    "West Virginia""WV",
    "Wyoming""WY",
    "District of Columbia""DC",
    "State not found message"
)

Assuming the state names are of type text you could be crazy and do the below: (NOTE this takes postal Codes to full names) 
State = SWITCH('Master Table'[Item State], "AL", "Alabama", "AK", "Alaska", "AZ", "Arizona", "AR", "Arkansas"
, "CA", "California", "CO", "Colorado", "CT", "Connecticut", "DE", "Delaware"
, "FL", "Florida", "GA", "Georgia","HI", "Hawaii", "ID", "Idaho", "IL", "Illinois", "IN", "Indiana", "IA", "Iowa", "KS", "Kansas"
, "KY", "Kentucky", "LA", "Louisiana", "ME", "Maine", "MD", "Maryland", "MA", "Massachusetts", "MI", "Michigan", "MN", "Minnesota"
, "MS", "Mississippi", "MO", "Missouri", "MT", "Montana", "NE", "Nebraska", "NV", "Nevada", "NH", "New Hampshire", "NJ", "New Jersey"
, "NM", "New Mexico", "NY", "New York", "NC", "North Carolina", "ND", "North Dakota", "OH", "Ohio", "OK", "Oklahoma", "PA", "Pennsylvania"
, "OR", "Oregon", "RI", "Rhode Island", "SC", "South Carolina", "SD", "South Dakota", "TN", "Tennessee", "UT", "Utah", "VT", "Vermont", "VA", "Virginia"
, "WA", "Washington", "WV", "West Virginia", "WI", "Wisconsin", "WY", "Wyoming","TX", "Texas","DC", "District of Columbia", "GU", "Guam", "PR", "Puerto Rico", "VI", "Virgin Islands",
"Unknown State" )

The above would go from state abbreviations to state name, all you need to do is reverse the arguments, it does work

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors