Video | Tableau | Data visualisation | Analytics

Length function to calculate lengths of spatial lines | New in Tableau 2023.2

In Tableau 2023.2 you can calculate the length of a line straight from the geometry, no more blending in distances.

Part ofWhat's new in Tableau 2023.2Tableau Functions
Watch on YouTube
  • The LENGTH function works only with line and multi-line string geometries, and you specify the units (miles, kilometres, feet, etc.) as a string argument.
  • You can skip working with the raw geometry and just use the calculated length for analysis, such as finding the Grand Union Canal as London's longest water body at 23.88 miles.
  • Accuracy depends entirely on how detailed the source geometry is, and more detailed polygons mean larger file sizes, so some generalisation is expected.
  • You can wrap the LENGTH function around the outline function to measure the distance around a polygon boundary.
  • Watch out for multi-polygon wards, as adding the polygon ID reveals that some boundaries are combinations of several polygons, which affects the calculated outline length.

Tableau 2023.2 adds a LENGTH function that calculates the length of line or multi-line geometries directly, so you no longer need to blend in pre-calculated distances. It also works when wrapped around the outline function, letting you measure the perimeter distance of polygon boundaries.

Demonstrated on a dataset of London water bodies (lines) and a separate viz of London ward boundaries (polygons) built with the outline function from an earlier release.

The Breakdown
  1. Build the length calculation 0:18

    Create a calculated field using the LENGTH function, pass it your spatial geometry field, then add a units argument as a string (e.g. "mi", "feet", "km"). It only works with line and multi-line string geometries, not polygons directly.

  2. Check it on the label 1:21

    Drag the new length field onto Label to confirm it's returning sensible values in the units you specified before using it further.

  3. Use lengths for analysis, not just display 1:33

    Once calculated, you can drop the raw geometry from view and use the length value itself for analysis body, ranking or filtering — for example finding the longest water body rather than just showing each one's length.

  4. Accuracy depends on source geometry detail 2:01

    Results are only as accurate as the underlying spatial data; highly detailed geometries produce larger file sizes, so real-world datasets are often generalised, giving you a good approximation rather than an exact figure.

  5. Other use cases 2:20

    The same approach applies to GPS traces for route analysis (e.g. optimising delivery routes against travel time) or environmental impact calculations like fuel use and CO2 tied to distance travelled.

  6. Wrap LENGTH around outline to measure perimeters 3:41

    You can nest the LENGTH function around the outline function on a polygon field to calculate the distance around a boundary — a further step beyond simple line lengths, useful for things like estimating fencing or coverage distance around an area.

  7. Watch for multi-polygon wards 5:01

    Some boundaries that look like a single shape are actually combinations of multiple polygons; adding the polygon ID to the view breaks these apart and gives a much more accurate, smaller outline length per polygon rather than one inflated combined figure.

Worth Knowing
  • LENGTH only accepts line or multi-line string geometries — you can't call it directly on a polygon, hence wrapping it around the outline function.
  • Perimeter/outline lengths can be misleadingly large if a boundary is actually made of several polygons merged together; check with polygon ID before trusting the figure.
  • More detailed, accurate geometry means larger file sizes, so expect some generalisation in your spatial data and treat lengths as estimates, not exact measurements.
Use It When

Reach for this when you need distances or perimeters from spatial data already in Tableau — route lengths, waterway or boundary lengths, coverage estimates — without having to pre-calculate and blend them in from another source.

How this Rollup was made provenance & method

A Rollup is drafted by AI from the video's transcript, then reviewed and edited by Tim. Everything used to produce this one is listed below — the model, the exact prompt, and the source video — so the process is transparent and reproducible.

Transcription
On-device — NVIDIA Parakeet v3 for recent videos, OpenAI Whisper large-v3 for earlier ones. The transcript never leaves the machine or gets published.
Drafting
Claude Sonnet 5 in the cloud, from that transcript.
Prompt
The exact Rollup prompt (v2) — the full system prompt, unedited.
Source video
Watch on YouTube
Drafted
5 July 2026 at 09:38
Reviewed & edited
5 July 2026 at 09:41 · by Tim Ngwena

Model + prompt + video is everything you'd need to recreate a Rollup like this yourself. The one thing we don't share is the transcript.

Rights. The video and its transcript are the property of TN Media Ltd. Unauthorised use or download is prohibited. © TN Media Ltd.