
How Do You Use LOOKUP in Tableau?
Carlos GarciaPublished How Do You Use LOOKUP in Tableau?
Almost every comparison you build in Tableau needs a value that is not on the row you are looking at. Month over month growth needs last month. Variance to target needs the first row of the period.
A running gap needs the figure two quarters back. The field itself holds only one number per row, so the comparison has to come from somewhere else in the table.
LOOKUP is the function that reaches across rows and fetches it. It is one of the most useful things in Tableau's calculation language and also one of the most misread, because the answer it returns depends on something that is not written in the formula at all.
This guide covers what LOOKUP actually does in Tableau's own words, the exact syntax, the step-by-step build, how Compute Using silently changes the result, when to use it, and what Tableau documents about its limits. Some of the most useful findings here are things Tableau does not say anywhere.
What Does LOOKUP Do in Tableau?
LOOKUP returns the value of an expression from a different row, specified as a position relative to the row being calculated. Tableau's own function reference puts it exactly this way: it "Returns the value of the expression in a target row, specified as a relative offset from the current row."
The signature Tableau publishes is LOOKUP(expression, [offset]). The expression is usually an aggregate such as SUM([Sales]). The offset is a whole number of rows: a negative offset reaches backward, a positive offset reaches forward.
That direction trips people up, so it is worth being blunt about it. In Tableau's own example, LOOKUP(SUM(Sales), 2) returns, for each row, the sales value from "2 quarters into the future." A positive offset looks ahead, not behind. If you want the previous period, you want -1.
The second half of the answer is the part that causes most of the confusion. LOOKUP is a table calculation, which means it does not run against your database the way a normal field does.
It runs against the rows that are already in your visualization, in the order and grouping that the view happens to have. Change the view and the same formula returns a different number.
Are your analytics setup and reporting actually telling you the truth? Get a free SEO and analytics audit and find out what your numbers are hiding.
Free audit
Where do you stand in AI search?
A manual SEO + AI search audit of your site: how ChatGPT, Gemini, Perplexity and Claude read and cite it today, and what to fix first. Report within 48 hours, no credit card.
Get my free auditOr have it all done: AI SEO services, $999 once
Why Does Tableau Need a LOOKUP Function At All?
Ordinary calculated fields in Tableau work one row at a time. A field can see everything on its own row and nothing else. That is enough for a margin or a ratio and useless for a comparison, because a comparison needs two rows.
Table calculations exist to solve exactly that. They are computed after the view is built, over the aggregated results already on screen, which is the only point at which the neighboring rows exist as a set Tableau can walk through.
What Is a Partition?
A partition is the group of rows a table calculation walks through. If your view breaks sales out by region and by month, Tableau can treat all the months inside one region as a partition, so LOOKUP steps month to month and resets when it reaches the next region.
Tableau's documentation describes the two jobs every dimension in the view has to take. Each one is used "either for partitioning (scoping) or for addressing (direction)." Partitioning fields define the groups. Addressing fields define the direction of travel inside each group.
This matters for LOOKUP more than for almost any other table calculation, because an offset of -1 is meaningless until you know which sequence it is stepping back along. One row back along months is a month-over-month change. One row back along products is nonsense.
What Are FIRST and LAST?
Tableau gives you two companion functions so that an offset can be anchored to the edge of the partition instead of to a fixed count. FIRST "Returns the number of rows from the current row to the first row in the partition," and LAST "Returns the number of rows from the current row to the last row in the partition."
The documentation tells you to "Use FIRST() + n and LAST() - n as part of your offset definition" when you want a target relative to the start or end of the partition rather than relative to the current row. Tableau's own worked example is LOOKUP(SUM([Profit]), FIRST()+2), which "computes the SUM(Profit) in the third row of the partition."
That is the pattern you want for index-style comparisons, where every row should be measured against the same baseline rather than against its immediate neighbor.
How Do You Write a LOOKUP Calculation, Step by Step?
Start by building the view you actually want to compare across. This is the step most guides skip, and it is the one that determines your answer. Put your dimension on Columns or Rows in the order you want LOOKUP to walk, and put your measure on the view so the numbers are already aggregated.
Create a calculated field. In Tableau Desktop, use Analysis then Create Calculated Field, give it a clear name such as Sales Previous Period, and enter the formula.
For a plain previous-row comparison, the formula is LOOKUP(SUM([Sales]), -1). For a change against the previous row, wrap it: SUM([Sales]) - LOOKUP(SUM([Sales]), -1).
For percentage change, divide by the earlier value and use ABS on the denominator so that a negative base does not flip the sign of your result. The full expression is (SUM([Sales]) - LOOKUP(SUM([Sales]), -1)) / ABS(LOOKUP(SUM([Sales]), -1)).
Drag the new field onto the view. Tableau will add a small triangle to the pill, which is how it marks a table calculation. That triangle is your reminder that the pill's value is view-dependent.
Now set the direction. Right-click the pill, choose Edit Table Calculation, and set Compute Using. This is not an optional refinement. It is the step that decides what -1 means.
Finally, check the edges. The first row of each partition has no previous row, so it will be blank rather than zero. That is correct behavior, and the next section explains why.
Most analytics problems are measurement problems, not reporting problems. Request a free audit and get a clear read on your tracking.
How Does Compute Using Change What LOOKUP Returns?
Compute Using is the control that tells Tableau which dimensions are for direction and which are for scope. Tableau's documentation is explicit that when you use the preset options, "Tableau identifies some dimensions as addressing and others as partitioning automatically," and that with Specific Dimensions "it's up to you to determine which dimensions are for addressing and which for partitioning."
The preset options Tableau exposes are Table across, Table down, Table across then down, Table down then across, Pane down, Pane across then down, Pane down then across, Cell, and Specific Dimensions. Table-level options walk the whole view. Pane-level options restart inside each pane, which is usually what you want when a second dimension is on the view.
There is one more behavior worth knowing, because it is easy to trigger by accident. Tableau documents that "If offset is omitted, the row to compare to can be set on the field menu." In other words, you can write LOOKUP(SUM([Sales])) with no offset at all and set the comparison row in the interface instead of in the formula.
That is convenient and it is also a maintenance trap. A reader of your workbook sees a formula with no offset in it and has no way to know what the calculation compares against without opening the field menu. If anyone else will ever maintain the workbook, put the offset in the formula.
A related subtlety from Tableau's documentation: with Compute Using set to specific dimensions whose values establish the sequence, those values establish "partitions by position" rather than partitions by value. The calculation is walking slots in the table, not matching on a key. This is the single biggest conceptual difference between LOOKUP and a spreadsheet lookup, and the next section is where it starts to hurt.
When Should You Use LOOKUP?
Use LOOKUP when the comparison you need is positional. Previous period, next period, same row last year in an ordered date axis, or a fixed baseline row anchored with FIRST(). These are all positional questions and LOOKUP answers them directly.
Use it when the comparison lives in the view rather than in the data. If your view is already aggregated the way a reader looks at it, LOOKUP compares what the reader is actually seeing, which is often exactly the right answer for a dashboard.
Use it when you want the calculation to follow the view. Swap the date part from month to quarter and a LOOKUP-based growth calculation keeps working, because it is defined relative to position rather than against a hardcoded period.
Do not use LOOKUP when the comparison is a join. If you need the value for a matching key that may not be present on the view, or may be in a different partition, you want a level of detail expression or a data-side relationship instead.
LOOKUP cannot find a row that is not on the view in the first place.
Do not use it when the ordering is not reliable. A LOOKUP down an unsorted dimension returns a value from whatever row happens to be adjacent, and it will do so silently and without error.
And do not use it when you need to filter on the result. This is where most people meet the order of operations problem, which is the first item in the next section.
What Are the Limitations of LOOKUP?
The first limitation is the one Tableau actually publishes, and it is short. "This function returns NULL if the target row cannot be determined." That is the whole documented failure mode. The first row of a backward LOOKUP is null, the last row of a forward LOOKUP is null, and anything outside the partition is null.
Nulls propagate, which is the practical consequence. A growth calculation built on LOOKUP will be blank on the first row of every partition, and a total built on top of it will quietly exclude those rows. Decide deliberately whether you want ZN() around it or whether a blank is the honest answer.
The second limitation is the order of operations, and Tableau states it plainly: "In the order of operations, a dimension filter is applied before a table calculation." Elsewhere on the same page: "Tableau applies the dimension filter before executing the table calculation." Filter out January and your February growth calculation will compare February against whatever row is now adjacent to it.
This is the single most common LOOKUP bug and it never throws an error. The fix is usually a table calculation filter, or putting the filtering dimension in the partition rather than in the filter shelf, but it starts with knowing that the filter ran first.
Here is a documented absence worth more than most of the facts above: Tableau's own order of operations page publishes the complete ordered list only as a diagram. The page says the order "includes the following, from top to bottom," and then shows a flowchart image. The text gives you individual pairwise statements, such as the dimension filter example above and that "FIXED level of detail expressions are computed before dimension filters are applied," and a statement that context filters are "executed before any other filter that you create in a worksheet." But the full sequence is not in words. Any article that confidently lists every stage in order is reading a picture, and so should you, from Tableau's page rather than from a blog.
A second documented absence: Tableau publishes no limitations for LOOKUP beyond the null return. Across the table calculation function reference, the table calculations overview and the order of operations page, there is no statement about whether a LOOKUP result can be filtered on, where in a workbook it can or cannot be used, whether it is row-level or aggregate, or whether it needs converting for any purpose.
If you read a hard rule about any of those somewhere, it did not come from Tableau.
A third absence, and the one that surprised us: Tableau names no version for when LOOKUP or table calculations were introduced. Not on the function reference, not on the overview page. If you need that for a compatibility decision, you will not find it in the documentation.
There is one general restriction worth carrying across from the overview page, because it explains a lot of surprising results. Table calculations "do not consider any measures or dimensions that are filtered out of the visualization." That is stated about table calculations generally rather than about LOOKUP specifically, and it is the same trap as the filter ordering seen from the other side.
Finally, the obvious one: performance. Table calculations run after the data comes back, over the result set, so a very wide view with many partitions gives Tableau more work to do at render time.
Tableau does not publish a row limit, a partition limit, or any numeric threshold for this anywhere in these pages, so treat any specific number you read elsewhere as invented.
Not sure whether your reporting is measuring the right thing in the first place? Get a free audit and start from the data rather than the dashboard.
How Does LOOKUP Compare to the Alternatives?
Against Tableau's other table calculations, LOOKUP is the general-purpose one. RUNNING_SUM, RUNNING_AVG and the rest of the running family accumulate along the partition and do not let you pick an arbitrary offset. The WINDOW family aggregates across a range rather than fetching a single row. INDEX and SIZE tell you where you are and how big the partition is.
PREVIOUS_VALUE is the closest relative and it is different in an important way: it refers to the previous value of the calculation itself, which makes it a recursion tool, where LOOKUP fetches the previous value of an expression.
Reach for LOOKUP when you want one specific neighboring value and for the running or window functions when you want a span.
Against level of detail expressions, the split is positional versus dimensional. A FIXED expression computes at a stated level of detail regardless of the view and is computed before dimension filters, which is exactly why it survives filtering where a table calculation does not. If your comparison is "versus the total for this customer" it is an LOD question. If it is "versus the row before this one" it is a LOOKUP question.
Against Excel, the mental model is genuinely different and this is where spreadsheet users get burned. Excel's OFFSET and INDEX address cells in a grid, and VLOOKUP or XLOOKUP match on a key.
Tableau's LOOKUP does neither: it walks positions within a partition of an already-aggregated view. If you are porting a spreadsheet, the key-matching work usually belongs in the data model or in an LOD expression, not in LOOKUP.
Against Power BI, the equivalent work is done in DAX with functions in the time intelligence and CALCULATE families, which filter a model rather than step through a rendered table.
That makes DAX comparisons less sensitive to how the visual is laid out and more dependent on having a proper date table. Neither approach is better in the abstract; they fail differently, and LOOKUP's failure mode is that it silently follows your view.
Against Google Sheets, there is no real equivalent, because the comparison there is just a cell reference to the row above. That simplicity is also the limitation: nothing adapts when you regroup the data.
The honest verdict across all of these: LOOKUP wins on speed of authoring and on following the reader's view, and loses whenever the answer has to survive a filter. If your comparison must be stable no matter what anyone clicks, build it with an LOD expression or in the data model instead.
Before you rebuild a single calculation, make sure the underlying data is trustworthy. Request your free audit.
Final Thoughts
LOOKUP is a small function with one genuinely tricky property: the formula does not contain the answer. LOOKUP(SUM([Sales]), -1) is a complete, valid calculation that means nothing until Compute Using says which sequence -1 steps along, and it will keep returning numbers even when that sequence is not the one you meant.
So the working habit is simple. Build the view first, write the offset into the formula rather than leaving it to the field menu, set Compute Using deliberately, and then check the first and last rows of every partition for the nulls Tableau told you to expect.
If a filter is anywhere near the calculation, assume the filter ran first until you have proven otherwise.
For a worked example of LOOKUP doing real work, our guide on how to show percentage change in Tableau builds the month-over-month calculation end to end, including the ABS denominator that keeps the sign honest.
And keep one thing in view the whole time. Tableau documents the syntax well and documents the limits barely at all: one null rule, a diagram instead of an ordered list, and no stated version history.
That is not a reason to distrust the function. It is a reason to test it against your own data rather than against someone else's confident article.
Want this done for you?
SEO Stuff gets businesses cited by ChatGPT, Gemini, Perplexity and Claude, and ranking in Google. Start with the free audit, a call, or the package.
See where you stand
A free, manual SEO + AI search audit of your site, with a report within 48 hours. No credit card, no sales call.
Get my free auditTalk it through
A free 15-minute call with the founder about whether AI search is a meaningful opportunity for your business.
Free strategy callHave it done
The Done-For-You Package: audit, 10 pages of content, 3 DR50+ placements, dashboard. $999 once, delivered in 21 business days.
See the package

