Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Is it possible to add start of the week date on excel file using the available tool?

Onemajor
7 - Meteor

Let's consider there is sales data that I download each week on Monday and only has two column.  Each week I have to open file and add start week date manually. 

Here is the data that I get: 

 

Productsales
A$100
B$120
C$500
D$300
E$130

 

Output that I am looking for: 

 

I wanted to achieve the following table each Monday where the Start Week date is added as new column for entire year of 2024.

 

For the first the week of 03/04/2024 to 03/10/2024, I am trying to get following table: 

 

companysalesStart Week Date
A$2003/4/2024
B$6003/4/2024
C$1003/4/2024
D$1503/4/2024
E$1203/4/2024

 

For the Week of 03/11/2024 to 03/17/2024. I am trying to get following table: 

 

companysalesStart Week Date
A$3003/11/2024
B$2003/11/2024
C$1003/11/2024
D$3003/11/2024
E$5003/11/2024

 

These two output are separate file, which is stored in a folder then I run workflow to read each file. 

13 REPLIES 13
HomesickSurfer
12 - Quasar

Hi @Onemajor 

 

This expression calculates the difference between today's day of the week (represented as a number from 'zero index' 0 to 6, where 0 is Sunday and 6 is Saturday) and Monday (1), then subtracts that difference from today's date to get this week's Monday, and finally formats it to display the day of the week.

 

Workflow package attached.  Extract to C:\Temp to execute and test.  It creates an output file in the same directory path as the input, with the 'Monday' date as suffix.

 

DateTimeFormat(DateTimeAdd(DateTimeToday(), - Mod(ToNumber(DateTimeFormat(DateTimeToday(), "%w")), 7) + 1, "days"), "%m/%d/%Y")

Commented:

DateTimeFormat(
/* Converts date-time data from ISO format to another specified format (f). Output to String data type. */     
DateTimeAdd(
// Adds a specific interval to a date-time value.
DateTimeToday(),
// Returns today’s date.
- // minus 'subtract'
Mod(
// Modulo of a number (n) divided by a number (d) (integer operation).
ToNumber(
// Converts a string (x), to a number.
DateTimeFormat(
/* Converts date-time data from ISO format to another specified format (f), in a specified language (l), for use by another application. Output to String data type. */
DateTimeToday(),
// Returns today’s date.
"%w")), 
// week
7) 
+ 1, 
"days"), 
"%m/%d/%Y")
// eg. 03/11/2024

 

Canvas screenshotCanvas screenshot

 

Onemajor
7 - Meteor

Hi @HomesickSurfer 

thanks for your response. Looks like you are extracting start week date column but that not what I am looking for. I need to add that start week day column in the table.

 

This is how the input looks like: 

companysales
A$100
B$120
C$500
D$300
E$130

 

 

HomesickSurfer
12 - Quasar

Hi @Onemajor 

 

I am not extracting any date, rather instead calculating it and appending it to the last column of the table.

Have you run the flow that I have provided?  The output is as follows...exactly what you seek.

 

Capture.PNG

apathetichell
19 - Altair

@Onemajor what was your issue with my workflow?

Labels