KNOWLEDGE BASE

Mapping IP Address Geocode Data


Published: 17 Mar 2017
Last Modified Date: 15 Sep 2017

Question

How to map IP address geocoding data. 

Environment

Tableau Desktop.

Answer

While Tableau software does not include IP address geocoding data, many websites on the Internet do, such as IPInfoDB.

Converting Starting IP Ranges into IP Addresses

Most IP databases include a column called "starting IP range." After you connect to the IP geocoding data, you convert those starting ranges into valid IP addresses so that they match the data you want to map.

You can convert the starting IP range decimal value to an IP address using four calculated fields, one for each segment (such as A, B, C, and D). Use the following formulas. The field that contains the IP start range is called [ip_start].

  • A = int([ip_start] / 16777216 ) % 256
  • B = int([ip_start] / 65536 ) % 256
  • C = int([ip_start] / 256 ) % 256
  • D = int([ip_start]) % 256

You create these calculated fields to get four new measures, one for each class.

Next, you combine these classes to create the valid IP address using the following formula.

str([Class A])+"."+str([Class B])+"."+str([Class C])+"."+str([class D])

After you create a calculation that displays an IP address in your geocoding data, join it to your fact data.

You can join on the Class A, Class B, and Class C fields that you created. Don't join on the Class D field: it represents an individual IP address and won't match data in the IP geocoding database.

Note: The full range of assigned IP addresses that can be geocoded is in the millions. We don't recommend importing this volume of data into Tableau using the custom geocoding feature. Instead, connect to the data directly. For more information, see the Mapping IP Address Geocode Data discussion in the Tableau Community Forums.

Additional Information

IP addresses are assigned to geographies, governments, corporations, and other entities as dictated by IANA.

For example, a city or province can choose from a range of addresses. The range includes a starting integer and an ending integer. Most IP address databases contain a "starting IP address integer" column. Each row of data contains an integer, and the end range is the next row.

Log files, such as a web log, Apache traffic log, or web analytics file, contain a valid IP address for the inbound request to the resource requested (such as a web page, iPhone app, ftp site, etc.).

For an example of mapping IP address geocode data, see northwestcoder's IP address workbook on Tableau Public.
Did this article resolve the issue?