Video | Tableau | Data visualisation | Analytics

What is the Lookup function in Tableau? Tableau Functions

LOOKUP looks simple — give it an aggregation and an offset — but the real magic, and the real headaches, are all in the direction you tell it to compute.

Part ofTableau Functions
Watch on YouTube
  • LOOKUP takes two arguments: an expression (usually an aggregation like SUM(Sales)) and an offset that tells Tableau how many rows forward (+) or back (-) to fetch the value from.
  • Compute Using controls direction — table across works along rows, table down along columns, and pane options confine the calculation to a sub-section of the view.
  • When LOOKUP can't find a target row it returns NULL, which is why you get gaps at the start or end of a partition where there's no data to pull from.
  • The way you build your table or chart locks in the pane, so a calculation can appear 'broken' simply because the layout constrains it — restructure the view to fix it.
  • Wrapping LOOKUP in ZN() converts those NULLs to zero, which is useful when subtracting a previous period to show year-on-year differences cleanly.

LOOKUP fetches an aggregated value from another row (forward or back) so you can compare it to the current row — but the direction it looks depends entirely on Compute Using and how your table or chart is structured, which is where most confusion happens.

Built on Sample Superstore: a table of sales by year, category/subcategory and month, used to demonstrate how LOOKUP behaves across different layouts and chart types.

The Breakdown
  1. Write the calculation: expression plus offset 3:33

    LOOKUP takes two arguments — an aggregation such as SUM(Sales), and an offset telling Tableau how many rows forward (positive) or back (negative) to pull the value from. You must supply both for the function to work.

  2. See it work: table across 7:16

    With Compute Using set to table across, LOOKUP moves left to right along the row, grabbing the value from the neighbouring column and returning it in the current cell — so an offset of 1 shows next month's figure in this month's row.

  3. Switch direction with table down 12:06

    Changing Compute Using to table down makes LOOKUP travel down the column instead of across the row — same calculation, same offset, but a completely different result because the direction of traversal changed.

  4. Understand nulls at partition edges 15:34

    Whenever LOOKUP can't find a target row — because you're at the very start or end of the data — it returns NULL. This happens by design wherever the offset would push you outside the available data.

  5. A 'broken' calculation is usually a layout problem 20:36

    If LOOKUP appears to do nothing, it's often because the way you've built the table has locked the pane down to a tiny area with nowhere to look. The fix is to restructure the table (move fields like measure names or category to a different position) rather than change the calculation itself — this only resolves once you rethink the table's structure.

  6. Same function, used in a chart 23:21

    LOOKUP works identically in a line chart — an offset of 1 shifts values back to create a shape resembling a lagged trend line, and larger offsets (6, 12) let you compare against a set number of periods ago, such as year-on-year with an offset of 12.

  7. Clean up gaps with ZN 28:31

    When you subtract a LOOKUP value from a current one (e.g. to show a period-on-period difference) the NULLs from missing history propagate into your subtraction. Wrapping LOOKUP in ZN() converts those NULLs to zero so the difference calculates cleanly, though the earliest rows still show NULL where no comparison exists at all.

Worth Knowing
  • LOOKUP's offset direction can feel counter-intuitive: a positive offset looks 'ahead' in the data but ends up shifting displayed values backward when charted, because of how the current row is anchored.
  • Rotating or pivoting a table also flips the compute direction (across becomes down and vice versa), so a working calculation can appear to break simply from rearranging the view.
  • The colour/formatting tied to a calculation can be a visual clue that its computed direction has changed after you've restructured the table.
  • Wrapping in ZN() only fixes nulls that arise from the subtraction — it won't create data for periods where there's genuinely no history to compare against.
Use It When

Reach for LOOKUP when you need to compare a value to a specific prior or future period — previous month, previous year, or a fixed number of periods back — inside a table or chart, and are prepared to control Compute Using deliberately rather than accept Tableau's default direction.

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.