Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Shift Day of Week Start and Week Number

jamesonian
5 - Atom

Hi All,

 

I need to do two things with a list of dates: set the week to begin on Wednesday then report a week number in full year plus week number format, similar to "%Y%U" in DateTimeFormat that aligns with the shifted week start. I also need the week number to be +1 since Alteryx starts week numbers on 0 and I need them to start on 1.

 

In the example below, the left is what Alteryx would do with the dates if I used formulas to get the day of the week and the week number in "%Y%U" format, and the right side is what I actually need. Any thoughts on how to get the right side?

 

DateDay of WeekYear and week number DateDay of WeekYear and week number
12/27/20200202052 12/30/20200202053
12/28/20201202052 12/31/20201202053
12/29/20202202052 1/1/20212202053
12/30/20203202052 1/2/20213202053
12/31/20204202052 1/3/20214202053
1/1/20215202052 1/4/20215202053
1/2/20216202052 1/5/20216202053
1/3/20210202100 1/6/20210202101
1/4/20211202100 1/7/20211202101
1/5/20212202100 1/8/20212202101
1/6/20213202100 1/9/20213202101
1/7/20214202100 1/10/20214202101
1/8/20215202100 1/11/20215202101
1/9/20216202100 1/12/20216202101

 

 

6 REPLIES 6
markcurry
12 - Quasar

Hi @jamesonian 

 

The following formula will gives you Weekdays 0-6 for Wednesday to Tuesday.

 

Mod(ToNumber(DateTimeFormat([Date],"%u")) + 4,7)

 

Your Year and week number value is a bit trickier unfortunately.

markcurry
12 - Quasar

Hi @jamesonian 

 

See the attached workflow, it's not the most elegant solution but gives you what you want.  It creates the Year and Week values for a date range, and then you can add that to your workflow.  Hope that helps.

 

Mark

jamesonian
5 - Atom

@markcurry That works! I had the days of the week set to start on Wednesday no problem but was tripping up on getting the week as I needed them. This solves that piece too. Thank you!

jamesonian
5 - Atom

Hi @markcurry ...thanks again for your previous solution. Now I have another question about it! 

 

How would you modify the flow you created so that:

 

1. The week starts on Friday (I figured out this part)

2. The first week of the year shifts forward one week from where your solution puts it (I have no clue)

 

For example, if I change the multi-row formula in your solution to have the weeks start on Friday I get this for 2021: 

jamesonian_0-1611607199301.png

 

What I want is for week 1 to start on Friday, January 8th instead of the 1st and the previous week starting Jan 1st should be week 53 of the previous year.

 

I know this is weird, but the use case is calculating promotional weeks for a retailer where a couple of their divisions use different promo weeks than the rest of the company. The rest of the company is using the logic in your previous solution.

 

Any ideas? Thanks! 

markcurry
12 - Quasar

Hi @jamesonian  Could you simply create the week starting on the Friday, so 1st January - 7th January is Week 1, then add a formula, if week = 1 set it to week 53 (and the year to 2020) otherwise subtract 1 from the week.  It will work for 2021.  So hopefully that does the trick for you.

Labels
Top Solution Authors