Reputation: 123
Using tableau, I am trying to analyze data on a weekly basis but with some modifications.
I want the first week of any given month to end on a Saturday with a minimum of one week.
Middle weeks are 7 days long (Sunday to Saturday).
The last week of a month Should be from Sunday to the last day of the month.
This question is very similar to the solution of this question but with minor differences: https://community.tableau.com/thread/230894
Here is an example for April
Week 1 has April 1 start date
Week 2 has April 12 start date
Week 3 has April 19 start date
Week 4 has April 26 start date
Upvotes: 1
Views: 69
Reputation: 123
This seems to work:
IF DAY([Update Time])<[ISO Time]
THEN IF [ISO Time] <=6
THEN DATEADD('day',7-[ISO Time],[Update Time])
ELSE DATEADD('day', 7-[ISO Time],[Update Time])
END
ELSE IF [ISO Time]<=6
THEN DATEADD('day',-[ISO Time],[Update Time])
ELSE DATEADD('day',7-[ISO Time],[Update Time])
END
END
Upvotes: 1