KNOWLEDGE BASE

Group Date Field Members Into a Single Column


Published: 29 May 2014
Last Modified Date: 23 Oct 2017

Question

How to group individual months together in one column for a specific year.

Environment

Tableau Desktop

Answer

The following instructions can be reviewed in the workbook attached below.

Step 1

  1. Create a new calculated field. In the attached workbook, this field is named "Sept -Dec 2010".
  2. In the formula field type:
    IF DATEPART('year', [Order Date]) = 2010 and DATEPART('month', [Order Date]) = 9 Then "Sept - Dec"
    elseif DATEPART('year', [Order Date]) = 2010 and DATEPART('month', [Order Date]) = 10 then "Sept - Dec"
    elseif DATEPART('year', [Order Date]) = 2010 and DATEPART('month', [Order Date]) = 11 then "Sept - Dec"
    elseif DATEPART('year', [Order Date]) = 2010 and DATEPART('month', [Order Date]) = 12 then "Sept - Dec"
    else DATENAME('month',[Order Date])
    end

Step 2

  1. Create a new calculated field. In the attached workbook, this field is named "Q3 & Q4 Combined".
  2. In the formula field type:
    If DATEPART('year',[Order Date]) = 2010 and DATEPART('quarter',[Order Date]) = 3 then "Q3 & Q4 Combined"
    elseif DATEPART('year',[Order Date]) = 2010 and DATEPART('quarter',[Order Date]) = 4 then "Q3 & Q4 Combined"
    else "Q" + DATENAME('quarter', [Order Date]) end
  3. Drag Order Date to the Columns shelf.
  4. Drag Q3 & Q4 Combined to the Columns shelf.
  5. Drag Sept -Dec 2010 to the Columns shelf.
  6. Drag Customer Name to the Rows shelf.
 
Did this article resolve the issue?