Spatial functions allow you to work with geographic objects such as points, lines, and polygons. They are commonly used with latitude/longitude data or spatial files (such as shapefiles or GeoJSON).
These functions make it possible to calculate distances, draw lines between locations, or analyse whether geographic areas overlap.
Some of the most common examples are listed below.
1. MAKEPOINT()
MAKEPOINT([Latitude], [Longitude])
- Creates a spatial point from latitude and longitude coordinates.
- If your dataset contains raw latitude and longitude fields,
MAKEPOINT()converts them into a spatial object that Tableau can treat as a location.
Example use cases:
- Mapping store locations
- Plotting accidents or events
2. MAKELINE()
MAKELINE([Start Point], [End Point])
- Creates a line between two spatial points.
- Since this function requires spatial points as inputs, it’s commonly used alongside
MAKEPOINT().
Example:
MAKELINE(
MAKEPOINT([Start Lat], [Start Lon]),
MAKEPOINT([End Lat], [End Lon])
)
This can be used to visualise:
- Travel routes
- Connections between locations
3. DISTANCE()
DISTANCE([Point A], [Point B], 'km')
- Calculates the distance between two spatial objects.
- You can specify the units:
'km'– kilometres'mi'– miles
Example use cases:
- Calculating distance from a customer to a store
- Measuring travel distances between cities
- Finding the closest location
4. BUFFER()
BUFFER([Location], 5, 'km')
- Creates a buffer zone around a spatial object.
- This generates a polygon that represents everything within a certain distance of a point or shape.
Real-world examples include:
- Finding customers within 5 km of a store
- Identifying areas affected by an event
- Creating service areas around facilities
5. INTERSECTS()
INTERSECTS([Area A], [Area B])
- Checks whether two spatial objects overlap or touch.
- The function returns TRUE or FALSE.
Typical uses include:
- Determining whether a location falls inside a region
- Identifying customers within a delivery zone
- Checking whether geographic areas overlap
6. DIFFERENCE()
DIFFERENCE([Polygon A], [Polygon B])
- Returns the portion of one spatial object that does not overlap with another.
This can be useful when analysing:
- Areas outside a service zone
- Remaining territory after subtracting overlapping regions
- Geographic exclusions
7. AREA()
AREA([Polygon])
- Calculates the area of a spatial polygon.
- The result is returned in square metres by default.
This can be helpful for:
- Measuring region sizes
- Comparing geographic coverage
- Analysing the size of service areas or buffers
