Casey
Casey

Reputation: 11

How to convert a field with 202008 to a date in Tableau

I am trying to convert a field that contains strings such as 202008, 202108 to a date field. I have tried the date() function, clicking on the measure and converting it to a date. I have also tried DATE(LEFT([Month],4)+"-"+RIGHT([Month],2)+"-01") but that will only return the year.

Upvotes: 1

Views: 860

Answers (1)

Fosstin
Fosstin

Reputation: 141

Using Tableau Desktop 2021.1, when I change the data type from String to Date, Tableau translates the strings to 8/1/2020 and 8/1/2021. If you are using an earlier version of Desktop, it is possible that this functionality is not present.

enter image description here

enter image description here

enter image description here

However, if changing the data type isn't working for you, the calculated field code you provided should actually work, you just need to change the date part from Year to Month/Day/Year using the Custom date part option.

enter image description here

enter image description here

Upvotes: 1

Related Questions