Loading

Displaying Only First or Last Value in a Partition

Publiceringsdatum: Mar 5, 2025
Uppgift
How to display only the first or last value in a partition.
Steg

To Show Only the Last Value in a Partition

  1. In Tableau Desktop, connect to Sample Superstore data.
  2. Drag Order Date to Columns and Sales to Text.
  3. select Analysis > Create Calculated Field.
  4. In the Calculated Field dialog box that opens, type a name for the field. The attached example workbook uses Last.
  5. In the formula field, type the following, and then click OK:
    IF LAST() = 0 THEN SUM([Sales]) END
  6. Drag SUM(Sales) off the Marks card and then drag the newly created calculated field to Text.

To Show Only the First Value in a Partition

  1. In Tableau Desktop, connect to Sample Superstore data.
  2. Drag Order Date to Columns and Sales to Text.
  3. select Analysis > Create Calculated Field.
  4. In the Calculated Field dialog box that opens, type a name for the field. The attached example workbook uses First.
  5. In the formula field, type the following, and then click OK:
    IF FIRST() = 0 THEN SUM([Sales]) END
  6. Drag SUM(Sales) off the Marks card and then drag the newly created calculated field to Text.
To view these steps in action, see the video below: 


 
Ytterligare resurser
The LAST() function returns the number of rows from the current row to the last row in the partition. The last row in a partition will return a 0.
Knowledge-artikelnummer

001458236

Bilagor

First_or_Last.twbx

347 KB

 
Laddar
Salesforce Help | Article