5 Replies Latest reply on Dec 3, 2018 8:42 AM by Gregg Hirshberg

    Parameter to select date (e.g. Year, Quarter, Month, Week, Day(date)) - Null shows for year/date(day)




      I am trying to create a parameter which switches between Year, Quarter, Month, Week, Day(date).

      I have followed this KB:.Dynamically Changing the Date Level | Tableau Software


      This works, but does not give me the outcome that I want, for example for quarter 2 it will show 1-4-17, quarter 3 1-7-17, etc.


      So I researched a bit and created a different calculation to show me what I want:

      CASE [Date Level Selector]

      WHEN 'YEAR' THEN STR(YEAR([Order Date]))

      WHEN 'Quarter' THEN STR(YEAR([Order Date])) + "/Q" + datename('quarter',[Order Date])

      WHEN 'Month' THEN datename('month',[Order Date])+" "+str(year([Order Date]))

      WHEN 'Week' THEN "Week " +str(datepart('week' , [Order Date]))

      WHEN 'DAY' THEN  str(date([Order Date]))



      This work for Quarter, Month and Week but for some reason Year and Day(date) are showing Null instead of the year or date? What is not correct in the calculation stated above?


      I have attached a workbook.