KNOWLEDGE BASE

How to Display Cumulative Totals up to a Specific Year and Month


Published: 19 May 2023
Last Modified Date: 30 May 2023

Question

How to display cumulative totals up to a specific year and month?

Environment

  • Tableau Desktop

Answer

Below is an example of displaying cumulative totals up to the year and month specified in the parameters using Sample-Superstore data.
User-added image

1. Create the parameters as follows;
 User-added image User-added image
2. Right-click Select year and Select month parameter, and select Show Parameter.
3. Create a calculated field and name it Total sales up to specific year and month.
IF ATTR(DATEPART('year', [Order Date])*100 + DATEPART('month', [Order Date])) <= [Select year]*100 + [Select month]
    THEN RUNNING_SUM(SUM([Sales]))
ELSE
    0
END
4. Add YEAR(Order Date) and MONTH(Order Date) to Columns.
5. Add Total sales up to specific year and month to Rows.
Did this article resolve the issue?