How to convert days ex Monday Tuesday etc in string data type to day type in Tableau

0 votes
I have a column called "Day of Week" that has information on the days of the week, such as "Monday," "Tuesday," "Wednesday," and so on. It always appears as string data type when I import it into Tableau. In order to conduct time series modelling, I need to change it to a day data type under Datetype. However, when I used the DATEPARSE method to convert a string to date format, it failed every time.

DATEPARSE('MMM',[Day of Week]) DATEPARSE('EE,EEEE','Day of Week'])

Could someone please assist me? Is there anything I'm missing?
Apr 4, 2022 in Tableau by Vaani
• 7,070 points
665 views

1 answer to this question.

0 votes

To create a date from constituent integers, use MAKEDATE.

With: Y,M,D as 2020,8,25

the date is created as MAKEDATE([Y],[M],[D])

The string day is not sufficient for the date calculation because there are several e,g, Mondays each month. You need the day of the month.

That said, if you do want to convert the string day to an integer, it can be done using CASE, as follows, where day is the string day:

CASE [Day] WHEN 'Sunday' THEN INT(1) WHEN 'Monday' THEN INT(2) WHEN 'Tuesday' THEN INT(3) WHEN 'Wednesday' THEN INT(4) WHEN 'Thursday' THEN INT(5) WHEN 'Friday' THEN INT(6) WHEN 'Saturday' THEN INT(7) END

Elevate your data visualization skills with our Tableau Course and unleash the power of insightful analytics.

answered Apr 5, 2022 by Neha
• 9,020 points

Related Questions In Tableau

0 votes
1 answer

How to convert string to date format in Tableau?

You can create the following calculated field: Dateparse('EEE ...READ MORE

answered Jun 30, 2018 in Tableau by ffdfd
• 5,550 points
6,407 views
0 votes
1 answer

How to refresh the extracted data source automatically in Tableau Desktop?

Hi AwesomeSauce, This comes up every so often!  Tableau ...READ MORE

answered Aug 14, 2018 in Tableau by Naruto
• 710 points
4,645 views
0 votes
1 answer

How to display days data based on date selected in the filter by the user.

You can create a parameter for dates. Select data ...READ MORE

answered Aug 15, 2018 in Tableau by AwesomeSauce
• 860 points
1,653 views
0 votes
1 answer

In Tableau, How to sum the last 7 days of the value?

It can be achieved easily by creating ...READ MORE

answered Mar 12, 2019 in Tableau by Cherukuri
• 33,030 points
17,164 views
0 votes
0 answers

Can PHP arrays hold items of different type?

The definition of an array in other ...READ MORE

Nov 16, 2022 in Database by Ashwini
• 5,430 points
803 views
0 votes
1 answer

Find length of string in R

You can try nchar > nchar("fast") [1] 4 > set.seed(10) > ...READ MORE

answered Apr 17, 2018 in Data Analytics by DataKing99
• 8,250 points
1,107 views
0 votes
1 answer

Removing all white-spaces from a string

You can use the 'str_replace_all()' function from ...READ MORE

answered May 16, 2018 in Data Analytics by Bharani
• 4,660 points
612 views
0 votes
1 answer

Converting a string to title case - R

library(tools) toTitleCase("this is sparta") [1] "this is Sparta" ...READ MORE

answered May 19, 2018 in Data Analytics by Bharani
• 4,660 points
1,578 views
0 votes
1 answer

How to upload data to Tableau Server in Python

Then install the tableau-api-lib utility for Python ...READ MORE

answered Mar 4, 2022 in Tableau by Neha
• 9,020 points
2,216 views
0 votes
1 answer

Convert String to Date in Tableau using DATEPARSE

You should be able to make the ...READ MORE

answered Mar 28, 2022 in Tableau by Neha
• 9,020 points
8,125 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP