Give a chestnut! Tableau Tips (11): Solving Dates by Calculating Fields
When using Tableau, have you encountered such a small problem: if the date is 20161107, it will not be recognized when imported into Tableau.
As shown below, if the column is selected as the date format, the column will all be null. It takes a long time to modify it in excel. Is there any way to solve this?
this In the "Hot a chestnut", Ada wants to share with everyone the Tableau technique is: through the calculation of the field processing date identification question.
After importing the data, create a calculated field as shown below:
DATA(
RIGHT(LEFT(STR([date]),6),2)+’/’+
RIGHT(STR([date]), 2)+’/’+
LEFT (STR ([date]), 4)
STR() returns a string, LEFT() returns the specified number of characters from the beginning, and RIGHT() returns the specified number of characters from the end.
Thus RIGHT (LEFT (STR ([date]), 6), 2) represents the return month, RIGHT (STR ([date]), 2) represents the return date, LEFT (STR ([date]), 4)) Returns the year, which gives the string "month/day/year".
Finally, we can get the date format by returning the date via DATA.
Have you learned the 20161107 field in Tableau by calculating the field to a small method of date format?