End of week day for a date in Tableau

4.8k Views Asked by At

I have date field in this format

dateID
>>20150617

And I want to get

end_of_week_day
>>2015-06-20

So for all the dates in a week, I want to get same end_of_week_day.

Is there any function in Tableau to do this? I am using Amazon Redshift.

1

There are 1 best solutions below

1
On BEST ANSWER

First thing is to convert that to a date. Use DATEPARSE to that. Or perhaps just convert the data type of the field and Tableau may understand.

Now for the actual calculation. You want to get the Saturday of that week. DATEPART, using 'weekday', will return a number, 1 for Sunday till 7 for Saturday. So:

DATEADD('day',7-DATEPART('weekday',dateID),dateID)

should do the trick