Reputation: 1516
Assume I am reading in a csv / text file into Tableau. I have a variable that contains years (yyyy). How do I convert this into an actual year in Tableau? I have tried. So, assume my data look like:
YEAR
2001
2002
2002
2001
2002
2004
I have tried DATEPARSE("yyyy", "YEAR")
but this returns: 1/1/00 12:00:00 AM
.
Thanks in advance.
Upvotes: 0
Views: 7693
Reputation: 11896
A more efficient alternative is to call makedate(YEAR, 1, 1), assuming that the field YEAR is an integer. This avoids any string conversions
Upvotes: 1
Reputation: 4310
Create a new calculated field with this as the formula:
DATEPARSE("yyyy", [YEAR])
The brackets around YEAR indicate that it is a field. Quotation marks (like you have) indicate that it is a hard-coded string.
Upvotes: 3