<< Back

UK Postcode mapping in 5 minutes


I have read a number of posts lately detailing approaches for handling mapping postcode data in the UK, so I thought I would write another one.  I think this is the fastest way to achieve it.

To map postcodes in Tableau, you somehow need to get the postcode

converted to a latitude and longitude.  There are many ways to do this, but I think this has the least steps.

Follow these steps to map the OUTCODE (the left hand side of a post code) to a Lat/Long.  The assumption is that you already have a dataset which includes POST CODE

Minutes 1 and 2 – Add a csv file to your copy of Tableau desktop, this tells Tableau the Lat/Long of the outcodes

You’ll need a csv file of outcodes, so I have posted one here.  Copy this file and save it.

Add it to tableau LIKE THIS…  Choosing the csv file from your save location.



Minute 3 – Create a calculated field which grabs the outcode from the postcode.  The function for the calculated field is something like this:

left([Postcode], find([Postcode], ” “)-1)

This finds the space in the postcode, and returns the left portion which is equivalent to the outcode in the csv file.



Minute 4 – Change the ‘geographic role’ of your calculated field to be outcode.  Outcode is now available as a geographic role because of the csv file added



Minute 5 – Now you should be able to plot the outcode against a measure.  Select the outcode field, select ‘number of records’ (for example) and show me should now offer you a map.  Hey pesto, postcode mapping!







Happy mapping.


Tom Brown

London, UK

21 thoughts on “UK Postcode mapping in 5 minutes

  1. Tom – thanks so much for this post that Joe at Tableau pointed me towards. The clear description and handy csv of lat/long for UK Postcode Outcodes had me up and running in 5 minutes as promised.

    I don't suppose you have any advice to help create polygon shapes for UK geographic areas (postcode areas, geographic regions, parliamentary constituencies etc) to create thematic maps? That would be really useful!

  2. Hi Andy,

    Thanks for your thanks! I have worked with polygon shapes before, so should be able to help with this. I'll email you…


  3. This is great, but sadly I REALLY need one including ALL the uk postcodes.. its inpossible to find on the net one already configured for use in Tableau…

    Any ideas?

  4. Hi Richie,

    Try this file – http://bit.ly/dS0As6 – its not perfect, some postcodes are missing Lat Longs, but I think it will be good for most requirements.

    It came from Wikileaks – although the web is littered with references to free postcode datasets being available for the UK, I can't find them either!

    Hope this helps.


  5. Hello Again, I found that link to the ordinance survey data myself while having a google before my post, however none of it is configured to automatically read like the one at the top of this page. You just get an error while trying to import it. Although I’m a keen IT'er I’m still very new to tableau and I’m a bit stuck as towards how to actually get it to display the data I need, specifically the north west of England

    65m people live in the UK, I thought somebody would of tackled this before me 🙂

    Thanks for your help Tom, do you happen to know what changes ill need to make and how to inport the data into tableau?


  6. Hi Tom

    I am trying to upload all the geographic coordinates of the UK, that is postcodes, regions, counties, local authorities, and parliamentary constituencies.

    I have all the data that I need, although not the longitude and latitude.

    It seems that uploading the outcodes, following your instructions work well, however I can not upload the counties, as it asks me for Country and State, saying that without these it can not upload.

    I would also need data for regions, local authority and constituencies. Could you shed any light on this.

    Uploading one of the tables from a different blog in the tableau format, for counties works fine, however when I then upload the outcodes, it does not let me blend the data as they have no common field. How do you solve this?

    Ideally what I want is to build my UK maps, sometumes by postcode (or outcode) also by region, county and so forth

    Could you please help?

    any help would be highly appreciated.



  7. Thanks Bob, if you found this useful, then you should try looking at this post to get access to all the UK postcode data:


    Also, if you'd like more information like this, we produce a newsletter designed to help people learning or using Tableau – drop me a line and I'll get you added to the distribution list (tom.brown@theinformationlab.co.uk)



  8. All I needed to do was import my data which had a list of outcodes and a measure and Then go into Map > Edit Locations… and then select UK from the list of countries. This then recognised all the outcodes. Could this be a new feature? I’m using version 8.

  9. Only got the product yesterday.

    This is fantastic.

    Will buy the full version now I can do this.

    Thanks very much


  10. I don’t get the option of geocoding under data? all i get is:
    connect & refresh

    what do i need to do to get the geo option?

  11. In response to Dopple, yes the latest version of Tableau can map UK outcodes out of the box. Again, if you have a list of postcodes and you need to take the outcodes from them then you can use a calculation such as:

  12. I’m not very experienced using Tableau. I have downloaded and saved the csv file but when I try to add the file to Tableau it is grayed-out and I can’t click on it and add it. Any advice? Thanks.

    1. In response to Caro, you need to run first the excel fonction (data) “Convert”, in order to separate Longitud and Latitud into different columns. Then you can import the csv.

  13. As mentioned by others, importing geocode data is no longer listed under “Data”. It is found under “Map”.

    I select the folder which countains the Outcode CSV file (this folder only contains that).

    I import… and then nothing happens whatsoever.

    Downloaded Tableau for the first time today. I played around with some fake data which included UK Postcode Districts, e.g. SW4, E4, N4 etc…
    Tableau recognises this as geographic data, but it simply plots as pin-prick points on a map.

    I need each postcode district to exist as a polygon.

    Googling for upwards of 90 minutes hasn’t yet yielded the answer. Remarkable.

    Downloading the TDE file via “the last word on UK…” article. Let’s see.

  14. I know that this is a an older post now, but has anyone tried a filled map in 2018.3 ?

    it appears to lose all definition and is a bit of a mess. I have just tried it again in 2018.1 and works fine, so the data and geocoding is fine, it appears 2018.3 is interpreting differently some how

    I have had a friend try in his 2018.3 and he has the same issue

    not sure I can give screenshots here, but if anyone can tell me how, or where to send to, I’ll happily share

Leave a Reply

Your email address will not be published. Required fields are marked *