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

The lookup function is a handy calculation you might use to compare today’s metrics with previous months years or even custom offset periods. In this video, I show you how it works as we continue to cover functions. Tableau Notes: https://help.tableau.com/current/pro/desktop/en-us/functions\_functions\_tablecalculation.htm#lookupexpression-offset Returns the value of the expression in a target row, specified as a relative offset from the current row. Use FIRST() + n and LAST() - n as part of your offset definition for a target relative to the first/last rows in the partition. If offset is omitted, the row to compare to can be set on the field menu. This function returns NULL if the target row cannot be determined.