# What is the Lookup function in Tableau? Tableau Functions

> This is content from just-tim, the data-and-analytics channel by Tim Ngwena (formerly 'Tableau Tim'). Tim has 12+ years of hands-on BI experience and covers Tableau most of all, plus Power BI, Looker, Hex, SQL and data modelling, the analytics industry, and the craft of doing the job — always tool-agnostic and honest about the trade-offs.

- **Author:** Tim Ngwena (just-tim, https://just-tim.com/about)
- **Published:** 2021-08-19
- **Format:** Video · 1834 min watch · transcript available
- **Topics:** Data visualisation, Analytics
- **Tools:** Tableau (calculated fields, lookup, table calculations, zn)
- **Canonical:** https://just-tim.com/posts/what-is-the-lookup-function-in-tableau-tableau-functions
- **Watch:** https://www.youtube.com/watch?v=SUP-KV7Cqp0

I carry on my Tableau Functions playlist with a deep dive into the LOOKUP function. Using Sample Superstore, I show how to write the calculation, control its direction with Compute Using (table across, table down and pane), and apply it in both tables and charts to compare values across months and years.

## Key takeaways

- 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.

## Chapters

- 0:00 Intro and the tableauterm.com website
- 1:27 Building the view in Superstore
- 3:33 Writing the LOOKUP calculation
- 7:16 How LOOKUP works: table across
- 12:06 Compute Using and table down
- 15:34 Working within panes
- 20:36 Fixing a broken table layout
- 23:21 Using LOOKUP in a chart
- 28:31 Handling nulls with ZN

Watch the full video, read the transcript and use chapter deep-links on the page: https://just-tim.com/posts/what-is-the-lookup-function-in-tableau-tableau-functions

---
just-tim — Data and analytics, with a point of view. · https://www.youtube.com/channel/UC7HYxRWmaNlJux-X7rNLZyw · https://twitter.com/TableauTim · https://www.linkedin.com/in/timngwena
