KNOWLEDGE BASE

Creating Dynamic Column Headers


Product(s): Tableau Desktop
Version(s): 8.3, 8.2, 8.1
Last Modified Date: 16 Aug 2016

This article demonstrates how you can create dynamic column headers in a dashboard using parameters and calculated fields.

Step 1: Create the View

  1. Download and open the Dynamic Headers workbook.
  2. From Dimensions, drag Order Date to the Columns shelf.
  3. From Dimensions, drag Customer, Product Name, and Order ID to the Rows shelf.
  4. In the view, right-click the Order Date header, and select Hide Field Labels for Columns.
  5. Right-click a year header, and clear Show Header.

Step 2: Create Parameters

  1. Right-click in the Data window and then select Create Parameter.
  2. In the Create Parameter dialog box, do the following, and then click OK:
    • Name the parameter. In the example workbook, the parameter is named Range 1 - Start.
    • For Data Type, select Date & Time.
    • For Display Format, select March 14, 2001.
    • Optionally, you can limit the range that will appear in the parameter controls by selecting Range for Allowable Values, and then setting maximum and minimum values.
  3. Right-click the parameter and then select Show Parameter Control.
  4. Repeat steps 1-3 three times to create Range 1 - Stop, Range 2 - Start, and Range 2 - Stop parameters.

Step 3: Create Calculated Fields

  1. Select Analysis > Create Calculated Field.
  2. In the Calculated Field dialog box that opens, do the following and then click OK:
    • Name the calculated field. In the example workbook, the calculated field is named Range 1 Sales.
    • In the formula field, create a calculated field similar to the following:
    • IF [Order Date]>= [Range 1 - Start] AND [Order Date]<=[Range 1 - Stop] THEN ([Sales]) ELSE 0 END

  3. Select Analysis > Create Calculated Field again.
  4. In the Calculated Field dialog box that opens, do the following and then click OK:
    • Name the calculated field. In the example workbook, the calculated field is named Range 2 Sales.
    • In the formula field, create a calculated field similar to the following:
    • IF [Order Date]>= [Range 2 - Start] AND [Order Date]<=[Range 2 - Stop] THEN ([Sales]) ELSE 0 END

  5. Select Analysis > Create Calculated Field a third time.
  6. In the Calculated Field dialog box that opens, do the following and then click OK:
    • Name the calculated field. In the example workbook, the calculated field is named Sales Difference.
    • In the formula field, create a calculated field similar to the following:
    • [Range 1 Sales] - [Range 2 Sales]

  7. Double-click Range 1 Sales, Range 2 Sales, and Sales Difference to add the fields to the view.
  8. In the view, right-click the Range 1 Sales header and clear Show Header.

Step 4: Create Title Sheets

  1. Select Worksheet > New Worksheet.
  2. Select Analysis > Create Calculated Field.
  3. In the Calculated Field dialog box that opens, do the following and then click OK:
    • Name the calculated field. In the example workbook, the calculated field is named Dynamic Range 1 Title.
    • In the formula field, create a calculated field similar to the following:
    • STR((DATENAME('month', [Range 1 - Start]))+ " " + DATENAME('day', [Range 1 - Start]) + ", " + DATENAME('year', [Range 1 - Start])) + " - " + str((DATENAME('month', [Range 1 - Stop]))+ " " + DATENAME('day', [Range 1 - Stop]) + ", " + DATENAME('year', [Range 1 - Stop]))

  4. From Dimensions, drag Dynamic Range 1 to Text.
  5. Repeat steps 1-2 to create a sheet with a Dynamic Range 2 Title calculated field. In the calculation field formula, replace Range 1 with Range 2.

Step 5: Combine the Sheets on a Dashboard

  1. Select Dashboard > New Dashboard.
  2. From Dashboard, drag Sheet 1 onto the dashboard.
  3. In the Dashboard pane, for Add new sheets and objects as, click Floating.
  4. Drag Sheet 2 onto the dashboard.
  5. In the view, right-click the Sheet 2 title, and then select Hide Title.
  6. Place Sheet 2 above the appropriate column, and then resize the dashboard object as needed.
  7. Repeat Steps 4-6 with Sheet 3.

The following view shows dynamic headers in a dashboard. Select a start and stop date from the quick filters on the right to update the headers.

 

Alternate Search Terms:Dynamic Headers, Dates, Parameters, Calculated Fields, Dashboards, Change
Did this article resolve the issue?