Predefined Calculation: Postcode Area Logic
This formula will match a postcode against the sets of postcode prefixes defined in Area 1, Area 2, Area 3 and Area 4.
This formula requires 6 inputs:
- Match on
- Area 1
- Area 2
- Area 3
- Area 4
The Match on option allows you to choose from:
Full Match: The full postcode, the postcode is normalised into the correct format before comparison.
Outcode: The outward code is the part of the postcode before the single space in the middle. It is between two and four characters long. A few outward codes are non-geographic, not divulging where mail is to be sent. Examples of outward codes include "L1", "W1A", "RH1", "RH10" or "SE1P". This is the default behaviour.
Area: The postcode area is part of the outward code. The postcode area is between one and two characters long and is all letters. Examples of postcode areas include "L" for Liverpool, "RH" for Redhill and "EH" Edinburgh. A postal area may cover a wide area, for example "RH" covers north Sussex, (which has little to do with Redhill historically apart from the railway links), and "BT" (Belfast) covers the whole of Northern Ireland.
Sector: The postcode sector is made up of the postcode district, the single space, and the first character of the inward code. It is between four and six characters long (including the single space). Examples of postcode sectors include "SW1W 0", "PO16 7", "GU16 7", or "L1 8", "CV1 4".
The inputs for Areas 1-4 accept multiple postcode prefixes, allowing you to create sets of prefix to match for an area.
This formula returns Area 1, Area 2, Area 3 or Area 4 if the postcode has a prefix that matches one of prefixes set in the area inputs.
Otherwise, the formula returns not-found.
The Postcode input is parsed. If an invalid postcode is found, the formula returns not-found.
The postcode is normalised and the Match On function called to get the prefix of the postcode for the match.
The prefix is compared to all prefixes specified in Area 1 in a case-insensitive manner. If the prefix matches, the formula returns Area 1.
If the prefix does not match Area 1, the same process is repeated for Area 2, then Area 3 and finally Area 4.
If no match is found in any area, the formula returns not-found.