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:
Product | sales |
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:
company | sales | Start Week Date |
A | $200 | 3/4/2024 |
B | $600 | 3/4/2024 |
C | $100 | 3/4/2024 |
D | $150 | 3/4/2024 |
E | $120 | 3/4/2024 |
For the Week of 03/11/2024 to 03/17/2024. I am trying to get following table:
company | sales | Start Week Date |
A | $300 | 3/11/2024 |
B | $200 | 3/11/2024 |
C | $100 | 3/11/2024 |
D | $300 | 3/11/2024 |
E | $500 | 3/11/2024 |
These two output are separate file, which is stored in a folder then I run workflow to read each file.
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
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:
company | sales |
A | $100 |
B | $120 |
C | $500 |
D | $300 |
E | $130 |
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.
@Onemajor what was your issue with my workflow?