Convert LOOKUP Functions In Tableau Desktop Workbook By Tableau Prep Builder
Published: 04 Jun 2020 Last Modified Date: 27 Oct 2022
How to convert the LOOKUP function used in Tableau Desktop by Tableau Prep Builder.
Tableau Prep Builder
In the attached packaged workbook, the LOOKUP function is originally used to get the previous order date per customer with Sample - Superstore. The following steps and the attached packaged flow file demonstrates how to get the same result using Tableau Prep Builder.
Open the Orders sheet of Sample - Superstore by Tableau Prep Builder
Add Clean Step.
In the Clean 1 step, click ... (More Options) of Order Date > Create Calculated Field > Rank.
Set Rank as below.
Select Rank at the first drop down list.
Group by Customer Name
Order by Defense Rank
Select Orders and Clean 1 step with pressing ctrl key, then right-click > Copy.
Right-click blank space > Paste.Orders(1) and Clean 1(1) step are generated.
In the Clean 1(1) step, click Create Calculated Field and create a calculated field (Index For Order Date)+1 including the following formula:
[Index For Order Date]+1
Delete all other field except (Index For Order Date)+1, Customer Name and Order Date.
Left join the Clean 1 step to Clean 1(1) step at the Join 1 step with the following join clause.
Index For Order Date = (Index For Order Date)+1
Customer Name = Customer Name.
Add Clean Step.
In the Clean 3 step, rename Order Date-1 to Previous Order Date and remove Index For Order Date and (Index For Order Date)+1
Table calculation functions in Tableau Desktop, such as the LOOKUP functions, sometimes get unexpected results depends on the layout or level of details of views. To avoid the issue, converting table calculations by Tableau Prep Builder would be a solution.
Thank you for providing your feedback on the effectiveness of the article.