KNOWLEDGE BASE

Using Canadian Postal Codes


Product(s): Tableau Desktop
Version(s): All
Last Modified Date: 16 Aug 2016

Tableau recognizes only the first three characters of the six-character Canadian postal code, that is, the segment called the forward sortation area.

If Canadian postal codes in your underlying data are formatted with all six alphanumeric characters, you can add a custom calculation to display the postal codes properly in your workbook.

Note: If you are connected to an OLAP (cube) data source, you can create a calculated member using MDX to display the postal codes properly in your workbook. For more information, see String Manipulations in Cubes, and Understanding Functional Differences between OLAP and Relational Data Source Connections.

Add a custom calculation for Canadian postal codes

To follow along with the steps in this article, download and open the attached Tableau workbook, Canadian Postal Codes.twbx. The steps use field names that are specific to the data source in this workbook.

Important: The calculated field described in this section works when the data in your view contains only Canadian postal codes. If you want your map view to include both Canadian and US postal codes, see the Working with multiple countries section for more information.

Step 1 

From the Measures pane, drag Longitude to the Columns shelf and Latitude to the Rows shelf.

Step 2 

Select Analysis > Create Calculated Field.

Step 3 

In the Calculated Field dialog box, do the following:

  1. For Name, type Postal Code.
  2. In the Formula text box, type the following formula. Confirm that it is valid, and then click OK.

    LEFT ([Customer Postcode], 3)

Step 4 

In Dimensions, right-click the calculation that you created in the previous step and select Geographic Role > ZIP Code/Postcode to assign a geographic role to the custom calculation.

Step 5 

From Dimensions, drag the Postal Code calculation to Detail on the Marks card. If the Canadian postal code marks do not appear, click the Update icon in the toolbar.

Working with multiple countries

You can use these steps to include both Canadian and other postal codes in your map views.

To follow along with the steps in this section, download and open the attached Tableau workbook, Working With Multiple Countries.twbx. The steps use field names that are specific to the data source in this workbook.

Step 1 

In your data source, modify the address information to add a separate column for country names. For the purposes of this example, the field is called Country.You can include the postal codes from other countries in the same column as the Canadian postal codes.

Step 2 

Do one of the following, depending on whether you created the custom calculation for Canadian postal codes.

  • If you created the calculation, modify it as follows:

    In the Data pane, right-click (control-click on Mac) Postal Code and select Edit.

  • If you did not create the calculation, do so now:

    Select Analysis > Create Calculated Field, and then type the name Postal Code.

Step 3 

Use the following formula:

IF [Country] = "Canada"
THEN LEFT ([Customer Postcode], 3)
ELSE [Customer Postcode]
END

Note: If some postal codes do not appear, you might need to edit their locations. For more information, see Edit Locations in Tableau Desktop Help.

 

Alternate Search Terms:map outcodes. post codes, international
Did this article resolve the issue?