MIP Logo

How to use Lookup () function in tableau?

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here. 

Lookup (expression, [offset]):

 

This returns the value of the expression in a target row, specified as a relative offset from the current row.

In this blog, I would like to explain how to use lookup functions to compare quarter-on-quarter sales data from Sample superstore data set.

 

Step 1:

  • Let us take Order Date Column and place year (order date) =2017 in filter in the shelf. Now let’s drag Quarter (Order date) from dimension and Sales from measure and place that in rows.

 

 

 

Step 2:

  • To find the difference between quarters such as Q1 and Q2 , we can use Lookup() function.
  • We can create a new calculation named “Previous quarter”:

 

 

 

  • The first part of the calculation (Expression)gets the data for the current row.

 

  • The second part of the calculation([offset]) looks at one row before the current row (-1).

 

  • Finally, it subtracts the current row from the previous row, to get the difference.

 

  • By using this Lookup() function,  it is easier to see the previous year or quarter or monthly or weekly sales .

 

Share this post