Skip to main content

Description

Normalizes a US state, territory, or the District of Columbia to its 2-letter USPS abbreviation. Use it to standardize state values from mixed sources before storing, deduplicating, or joining on state. Matching is case-insensitive and tolerates extra whitespace, including non-breaking spaces and zero-width characters. Repeated internal whitespace is collapsed, so 'New York' matches 'New York'. An already-valid 2-letter USPS code passes through and is uppercased, so the function is safe to apply to columns that mix full names and abbreviations. Coverage includes all 50 states, the District of Columbia, and the 5 major US territories (Puerto Rico, Guam, American Samoa, US Virgin Islands, Northern Mariana Islands). 'Washington' returns 'WA' (the state). Only explicit District of Columbia variants return 'DC': 'Washington DC', 'Washington D.C.', 'Washington, DC', 'District of Columbia', and 'D.C.'.

Syntax

NormalizeState(string_expression)

Examples

NormalizeState('California') returns 'CA'. NormalizeState('new york') returns 'NY'. NormalizeState('ca') returns 'CA'. NormalizeState('District of Columbia') returns 'DC'. NormalizeState('Not A State') returns null.

Return value datatype

String

Impact of null value

If input is null, returns null. If the input cannot be parsed as a valid state, territory, or 2-letter USPS code, returns null.
Last modified on August 14, 2026