Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Using a power BI script for creating a calculated column, how can we convert a State Name Table into a State Abbreviation?
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"
)
The above would go from state abbreviations to state name, all you need to do is reverse the arguments, it does work