Changing Date Formats to Match the Dynamic Date Level Selection in a Parameter

Published: 18 Jul 2016
Last Modified Date: 19 Sep 2017


How to dynamically update the format of dates after setting up a visualization for dynamic date levels (as described in the following Knowledge Base article: Dynamically Changing the Date level).


Tableau Desktop


You can change the dates' formatting through the use of String, Datename, and Datepart function in addition to manual sorting. For more information, please see the steps below:
  1. First, adjust the Case statement of your calculated field, so that the formula becomes similar to: 
    CASE [Date Level Selector]
    WHEN 'Year' THEN STR(YEAR([Order Date - Year]))
    WHEN 'Month' THEN DATENAME('month',[Order Date - Month]) + " " + STR(YEAR([Order Date - Month]))
    WHEN 'Quarter' THEN "Q" + STR(DATEPART([Order Date - Quarter])) + " " + STR(YEAR([Order Date - Month]))
  2. Then, because the String function will reorder the fields in the view alphabetically, right-click the calculated field with the Case Statement
  3. And manually sort the Months field into the desired order. 
Did this article resolve the issue?