Last Modified Date: 08 Jul 2022
Environment
- Tableau Desktop
Answer
The workbook attached to this article demonstrates the below solution using sample Superstore data set, assuming the fiscal year starts in July.Step 1 - Create a Parameter
- Right-click anywhere in the Data pane of Tableau Desktop and select Create Parameter...
- Fill in the different fields as described below:
- Name: Calendar Type
- Data type: String
- Allowable values: List
- Manually add the following values: Calendar, Fiscal
Step 2 - Create three calculated fields
- Select Analysis > Create Calculated Field...
- Name the calculated field: Display Month
- Enter the following formula and click OK:
DATENAME('month', [Order Date])
- Select Analysis > Create Calculated Field...
- Name the calculated field: Display Year
- Enter the following formula and click OK:
CASE [Calendar Type] WHEN "Calendar" THEN DATENAME('year', [Order Date]) WHEN "Fiscal" THEN "FY" + DATENAME('year', DATEADD('month', 6, [Order Date])) END
- Select Analysis > Create Calculated Field...
- Name the calculated field: Month Sort
- Enter the following formula and click OK:
CASE [Calendar Type] WHEN "Calendar" THEN DATEPART('month', [Order Date]) WHEN "Fiscal" THEN DATEPART('month', DATEADD('month', -6, [Order Date])) END
Step 3 - Build the view
- Drag [Display Year] and [Display Month] on Columns
- Drag Sales to Rows.
- Right-click on [Display Month] and select Sort...
- Choose "By Field" and select [Month Sort]
- Choose "Minimum" aggregation
- Then click OK
Additional Information
Discuss this article... Feedback Forum
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