Tableau LOOKUP() Function
top of page

Tableau LOOKUP() Function

Writer's picture: Bernard KilonzoBernard Kilonzo
Tableau LOOKUP() Function

This function returns the value of the expression in a target row, specified as a relative offset from the current row. You can use FIRST()+1 and LAST()-1 as part of your offset definition for a target relative to the first/last rows in the partition.

The syntax: LOOKUP(Expression, [Offset])

LOOKUP() function is one of the most useful table calculations in Tableau. In this article, I will demonstrate to you how you can use this function to compute difference and percent difference, respectively.

Computing difference

Using Superstores data set, I will use this function to compute Sales difference from the previous month for different months of the year. But before that, let’s create the table layout using Month Year of Order Date and Sales as shown below.

table summary

LOOKUP(SUM(Sales), -1)

Using the above LOOKUP() function, Tableau returns a table with the previous Sales value shifted and aligned with the current value.

Let’s add this new calculation to the view.

table summary

Therefore, using this function one can compute Sales difference by subtracting the previous value from the current value as shown below;

Computing difference using LOOKUP() function

Adding this computation to the view results.

table summary

(Which is the Sales difference from the previous month’s Sales)

The same calculation can be used to compute Sales difference from the previous year for different product Sub-Category’s, as shown in this table.

table summary

Computing percent difference

Extending the above calculation by diving it with the previous value as shown below returns the percent difference.

Computing percent difference using LOOKUP() function

Applying this calculation on the tables, we’ve.

table summary
table summary

I hope this article was helpful to you, to receive more of the Tableau tips and tricks, kindly join our mailing list by subscribing below.

If you like the work we do and would like to work with us, drop us an email on our Contacts page and we’ll reach out!

Thank you for reading!

Original.png

We Support You Deliver Business-Focused Solutions That Enable Data-Driven Decision Making.

  • Tableau profile
  • YouTube
  • White LinkedIn Icon
  • Facebook
  • X

QUICK LINKS

CONTACT US

+254 738 307 495

East Gate Mall, Donholm

3rd Floor Suite No. 3i

Nairobi, Kenya

Join our mailing list

bottom of page