ISO Country | ISO_COUNTRY
Syntax
ISO_COUNTRY( [value], [returnType = "CODE"] )
Parameters
value
The input TEXT that will be converted to or from a country code.
If it is not a TEXT value, an empty TEXT value will be returned.
returnType optional
Determines whether or not to convert from or to a country code.
"CODE" will convert the input to a country code.
"NAME" will return the full country name from a country code.
Defaults to "CODE" if omitted.
Return Value
A TEXT value. Will be the abbreviated country code when returnType is set to "CODE". Will be the full country name when returnType is set to "NAME". Will always return an empty TEXT value if the submitted code or name is not found.Description
Takes a TEXT input and converts it into a the standard code abbreviation. Can also be used to validate country codes or country names.Examples
Convert a country name into an ISO code.ISO_COUNTRY('Sweden')
# returns "SE"
Convert a country ISO code into the country name.
ISO_COUNTRY("SE", "NAME")
# returns "Sweden"
Check to see if a country code is valid
ISO_COUNTRY("SE", "CODE")
# returns "SE"
ISO_COUNTRY("XX", "CODE")
#returns "" because there is no "XX" country code
Check to see if a country name is valid
ISO_COUNTRY("Sweden", "NAME")
# returns "Sweden"
ISO_COUNTRY("Fakelandia", "NAME")
#returns "" because there is no country named "Fakelandia".
Return an empty TEXT value if no value or a non string value is provided
ISO_COUNTRY(null)
# returns ""
ISO_COUNTRY(undefined)
#returns ""
ISO_COUNTRY(45)
#returns ""
Handles 3 character country codes
ISO_COUNTRY("USA")
# returns "US"