Last Modified Date: 20 Jul 2023
Environment
Tableau DesktopAnswer
Option 1 (YTD)
- Select Analysis > Create Calculated Field
- Name the field YTD Sales, enter the following calculation, then click OK:
[Order Date] <= TODAY() AND
DATETRUNC( "year", [Order Date]) = DATETRUNC("year", TODAY() ) - Drag YTD onto the filter shelf and select "True"
Option 2 (MTD)
- Select Analysis > Create Calculated Field
- Name the field MTD Sales, enter the following calculation, then click OK:
[Order Date] <= TODAY() AND
DATETRUNC( "month", [Order Date]) = DATETRUNC("month", TODAY() ) - Drag MTD onto the filter shelf and select "True"
Option 3 (Dynamic MTD/YTD)
- Create a parameter and name it "
YTD/MTD
" - String - Create a parameter and name it "Anchor Date" - Date
- Create a parameter and name it "Offset" - Int
- Select Analysis > Create Calculated Field
- Name the field Dynamic Sales, enter the following calculation, then click OK:
[Order Date] <= DATEADD( [Date Part],[Offset], [Anchor Date] ) AND
DATETRUNC( [Date Part], [Order Date]) = DATETRUNC([Date Part], DATEADD([Date Part], [Offset], [Anchor Date] )) - Drag MTD onto the filter shelf and select "True"
Additional Information
To view the steps showed in the below video, please expand the above section. Note: the video has no sound.Thank you for providing your feedback on the effectiveness of the article.
Open new Case
Continue Searching
Knowledge Base
Community
Product Help
Training and Tutorials