Skip to content

UK postcode formatting

As there are too many postcodes in the UK to make a sensible selector pick list (about 1.8 million), it's common practice to use parts of the postcode for selection and analysis. Unfortunately, you can't easily split a UK postcode at a fixed number of characters. To assist with this, FastStats can prepare structured postcodes from the normal printable postcode. The FastStats postcode transformations take UK postcodes as input and can transform the postcode into one of the following formats:

  • AA - Postal Area (about 124 unique entries)
  • AADD - Postal Area and Postal District (about 2971 unique entries)
  • AADDL - Postal Area, Postal District, and London Suffix
  • AADDLS - Postal Area, Postal District, London Suffix, and Postal Sector (about 10,631 unique entries)

It's usual practice to split the postcode at the postcode area and district.

To apply, set UK Postcode to AADDL to be the mapping on the PostDist field.

Tip

Use Add Field to clone the postcode field and call it PostDist. Apply the mapping to the PostDist variable. In this way you have the original format postcode and the sort formatted version.

Other UK postcode transformations

The transformations add spaces to their output so that the values sort in the order users expect. The examples on this page show each space as an underscore (_).

UK Postcode to AADDL

This takes a standard UK postcode and produces a 5 character sort formatted post district selector. The incoming postcode must be at least 5 characters in length. For example:

  • CV34 4AX → CV34_
  • M20 2DF → M_20_
  • SW1A 4WW → SW_1A

This function is useful for UK postcodes because the standard format doesn't allow data to be sorted into the sequence users expect. The Postcode Area is the first two characters and this can be used as a Summary Code.

UK Postcode to AADD

This takes a standard UK postcode and produces a 4 character sort formatted post district selector. The incoming postcode must be at least 4 characters in length. For example:

  • CV34 4AX → CV34
  • M20 2DF → M_20
  • SW1A 4WW → SW1A (note no space)

This format doesn't sort as consistently as AADDL (due to the London suffix) but is common in Geographic Information System (GIS) applications.

UK Postal district to AADDL

This takes a first half postcode and produces a 5 character AADDL sort formatted post district selector. The incoming data must be at least 5 characters in length. For example:

  • CV34 → CV34_
  • M20 → M_20_
  • SW1A → SW_1A

UK Postal district to AADD

This takes a postcode defined up to the post district level, and produces a 4 character AADD sort formatted post district selector as used in most mapping packages. The incoming data must be at least 4 characters in length.

PostArea (UK Postcode to AA)

This takes a standard UK postcode and produces a two character postal area. For example:

  • CV34 4AX → CV
  • M20 2DF → M_
  • SW1A 4WW → SW

PostSect (UK Postcode to AADDLS)

This takes a standard postcode and produces a six character AADDLS sort formatted postal sector. For example:

  • CV34 4AX → CV34_4
  • M20 2DF → M_20_2
  • SW1A 4WW → SW_1A4

The following table compares the output of each mapping for the same postcodes:

Examples

Input postcode Mapping Output
CV34 4AL AA CV
CV34 4AL AADD CV34
CV34 4AL AADDL CV34_
CV34 4AL AADDLS CV34_4
SW1A 7WW AADD SW1A
SW1A 7WW AADDL SW_1A
SW1A 7WW AADDLS SW_1A7
B1 7AL AADD B__1
B1 7AL AADDL B__1_
B1 7AL AADDLS B__1_7
E1W 6AP AADDL E__1W
E1W 6AP AADDLS E__1W6