Tableau LAST function to find the Recent Order Date

While analyzing the sales pattern, it is important to identify the repeated customers and determine their recent orders. This article shows how to use this Tableau LAST function to find the recent order date by a product, category, Subcategory, or customer name with examples.

Tableau LAST function

The Tableau LAST function is helpful to find the last record or row in a table, pane, etc. If you use it on the whole table, it returns the numeric value from n to 0, where 0 is the last record and n is the first record. However, if you use the assignment operator, it will return a boolean True or False.

The syntax of the Tableau LAST function is as shown below.


To demonstrate the Tableau LAST function to find the recent order date by a customer or product, we use the Sample Superstore. Drag and drop the Sales to the Columns Shelf and the Customer Name and Order Date to the Rows shelf.

Tableau LAST function to find the recent order date

Please change the Year of Order Date to Extract date and change it from Continuous to Discrete. If the default Mark type shows the Line Chart. Please change the Marks type to Bar Chart. For the remaining charts in Tableau, please click here.

A simple bar chart

First, we must create a calculated Field to use the built-in LAST function. Use the Analysis Menu and select the Create Calculated Field.. option to do this. Please refer to the Table Functions, other Functions, and Excel Source articles.

Let me rename it as the Last Order and write the below expression. It will return True if it is the last row of the section. In this case, it returns True if it is the last row of each customer.

LAST() = 0
Create a calculated field to write expression

Drag the newly created calculate field to the Rows shelf. By default, it will perform the Table(down) calculation. So, the Tableau LAST function returns True for the last customer record in the whole table by order date. Next, click the Down arrow beside the Last Order and click the Edit Table Calculation option.

Tableau LAST function to find the Recent Order Date using True and False

Please change the Compute using from Table(down) to Specific Dimension and checkmark the fields. Remember, the Fields must be in the same order. Next, select Customer Name as the Restarting every option. Once. You change them, and you can see the True for the last row of every customer, i.e., the customer’s last or latest order.

Edit The table calculation too change the compute using option

Use the control or command button to select the last order calculated field in the Rows Shelf and drag it to the Filters Shelf. By default, the window below will appear. Choose True and click OK. It means it will show the Customer’s last orders.

Add the calculation totes filter shelf

The Tableau LAST function screenshot below finds and shows the recent or the latest customer order date.

Tableau LAST function to find the Latest or Recent Order Date. by. customer. or product

Let me find out the latest order placed by the product subcategory. To do so, remove the Customer Name from the Rows Shelf and the Last Order from the Filters Shelf. Next, add a Subcategory to the Rows Shelf.

Click the down arrow beside the Last Order, choose the Edit Table Calculation, and choose the Subcategory.

Tableau LAST function to find the Recent Product Subcategory Order Date 7

Next, drag the Last order from the Rows shelf to the Filters shelf to remove the True/False column. Next, add a Subcategory to the Color shelf and add colors to the bar chart. The below Tableau LAST function image shows the latest or recent orders from the product subcategory based on the order date.

Tableau LAST function to find the Recent or Latest Product Subcategory Order Date by customer