1 Reply Latest reply on Jul 31, 2017 9:56 AM by Dave Jobling

    If No Zip Code Match, defualt to Country

    Santiago Perez

      I am trying to create a map that includes data from lots of countries that Tableau does not yet support postalcodes for, or which do not have postal codes altogether. THe desired behaviour is that if the map is not able to plot a postal code, it plots the Country instead. So you would end up with zip code data in North America, Most of Europe, Brazil etc but country data in Mongolia, Ireland and other non-postal code supported areas.

       

      Here's what I have currently. THe case statement handles the different ways you need to massage the postal codes so that Tableau can interpret them in different countries. The ifnull() part is my attempt to have it return the country if a postal code is invalid

      ifnull(

      Case[Operating Country] when "Canada"

      then

      left([Shippingpostalcode - Split 1],3)

      when "United Kingdom"

      then left([Shippingpostalcode - Split 1], find([Shippingpostalcode - Split 1], " ")-1)

      When "Australia"

      then [Shippingpostalcode - Split 1]

      else

      [Shippingpostalcode - Split 1] end,

      [Operating Country])

       

      Of course the non-standard postal code is not really null, so it doesn't work. But if anyone has any ideas for how you could show the number of companies by postal code where available and the number of companies per country where not within a single map, I would be greatful.

       

      Best,

      Santiago