KNOWLEDGE BASE

How To Calculate The Value Of The Same Day Of The Previous Month


Published: 28 Nov 2021
Last Modified Date: 02 Dec 2021

Question

How to calculate the value of the same day of the previous month.

Environment

  • Tableau Desktop

Answer

Using a Table Calculation and the LOOKUP function, you can calculate the value on the same day of the previous month.

Steps
  1. Connect to Sample - Superstore 
  2. Right click [Order Date] and drag and drop it to the Columns and select [MONTH(Order Date)].
  3. Right click [Order Date] and drag and drop it to the Columns and select [DAY(Order Date)].
  4. Double click [Sales] measure and add it to the view.
  5. Create a Calculation field named "Sales(Previous Month)" with the following calculations.
         LOOKUP(SUM([Sales]),-1)
  6. Double click [Sales(Previous Month)] and add it to the view.
  7. Right click [Sales(Previous Month)] in Measure Values, and select [Edit Table Calculation]. Set the following values.
         Compute Using : Specific Dimensions
         Check only Month of Order Date.
         Sort order : Specific Dimensions.

See the attached workbook for details.
Did this article resolve the issue?