PowerQueryUser
New Member
- Joined
- Aug 27, 2021
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
I am facing a power query challenge.
I have a csv file with many line items.
The first columns are some material descriptions.
The following columns are weekly dates MM/DD, but without year information.
The csv file covers around 3 years.
Following an example of the structure. Please consider each MM/DD represents one column header.
Just for explanation I added the year and separated in different lines.
2021:
8/1 8/8 8/15 8/22 8/29 9/1 9/5 9/12 9/19 9/26 10/1 10/3 10/10 10/17 10/24 10/31 11/1 11/7 11/14 11/21 11/28 12/1 12/5 12/12 12/19 12/26
2022:
1/1 1/2 1/9 1/16 1/23 1/30 2/1 2/6 2/13 2/20 2/27 3/1 3/6 3/13 3/20 3/27 4/1 4/3 4/10 4/17 4/24 5/1 5/8 5/15 5/22 5/29 6/1 6/5 6/12 6/19 6/26 7/1 7/3 7/10 7/17 7/24 7/31 8/1 8/7 8/14 8/21 8/28 9/1 9/4 9/11 9/18 9/25 10/1 10/2 10/9 10/16 10/23 10/30 11/1 11/6 11/13 11/20 11/27 12/1 12/4 12/11 12/18 12/25
2023:
1/1 1/8 1/15 1/22 1/29 2/1 2/5 2/12 2/19 2/26 3/1 3/5 3/12 3/19 3/26 4/1 4/2 4/9 4/16 4/23 4/30 5/1 5/7 5/14 5/21 5/28 6/1 6/4 6/11 6/18 6/25 7/1 7/2 7/9 7/16 7/23 7/30 8/1 8/6 8/13 8/20 8/27
In the consecutive power query I unpivot the dates.
Then I format each date as data type date.
The issue is, that all dates are formatted with the current year, e.g. 1st August 2021.
I could solve the issue for two years with a conditional column and comparing if the line item date is in the past. Then I knew, that the line time must be in 2022.
But now facing also 2023, this approach does not work anymore.
Do you have any idea, about a logic to format the columns with correct years?
You might recognize, that the dates are basically a weekly pattern. But each month starts also with an additional column. e.g. 29th Aug, 1st Sept, 5th Sept.
I really appreciate a hint, what kind of logic I could apply to solve this challenge.
Thank you very much.
I have a csv file with many line items.
The first columns are some material descriptions.
The following columns are weekly dates MM/DD, but without year information.
The csv file covers around 3 years.
Following an example of the structure. Please consider each MM/DD represents one column header.
Just for explanation I added the year and separated in different lines.
2021:
8/1 8/8 8/15 8/22 8/29 9/1 9/5 9/12 9/19 9/26 10/1 10/3 10/10 10/17 10/24 10/31 11/1 11/7 11/14 11/21 11/28 12/1 12/5 12/12 12/19 12/26
2022:
1/1 1/2 1/9 1/16 1/23 1/30 2/1 2/6 2/13 2/20 2/27 3/1 3/6 3/13 3/20 3/27 4/1 4/3 4/10 4/17 4/24 5/1 5/8 5/15 5/22 5/29 6/1 6/5 6/12 6/19 6/26 7/1 7/3 7/10 7/17 7/24 7/31 8/1 8/7 8/14 8/21 8/28 9/1 9/4 9/11 9/18 9/25 10/1 10/2 10/9 10/16 10/23 10/30 11/1 11/6 11/13 11/20 11/27 12/1 12/4 12/11 12/18 12/25
2023:
1/1 1/8 1/15 1/22 1/29 2/1 2/5 2/12 2/19 2/26 3/1 3/5 3/12 3/19 3/26 4/1 4/2 4/9 4/16 4/23 4/30 5/1 5/7 5/14 5/21 5/28 6/1 6/4 6/11 6/18 6/25 7/1 7/2 7/9 7/16 7/23 7/30 8/1 8/6 8/13 8/20 8/27
In the consecutive power query I unpivot the dates.
Then I format each date as data type date.
The issue is, that all dates are formatted with the current year, e.g. 1st August 2021.
I could solve the issue for two years with a conditional column and comparing if the line item date is in the past. Then I knew, that the line time must be in 2022.
But now facing also 2023, this approach does not work anymore.
Do you have any idea, about a logic to format the columns with correct years?
You might recognize, that the dates are basically a weekly pattern. But each month starts also with an additional column. e.g. 29th Aug, 1st Sept, 5th Sept.
I really appreciate a hint, what kind of logic I could apply to solve this challenge.
Thank you very much.