Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello all.
Need help creating a date table in Power Query. Require date column and week number but start of the week should be Tuesday. Is it possible and could you help with the M code?
Solved! Go to Solution.
Hello @Anonymous
this code creates a table with dates starting from beginning of 2018 for 3000 days and adds a new column with the week of the year, using tuesday as starting day
let
Source = List.Dates(#date(2018,1,1), 3000, #duration(1,0,0,0)),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type date}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "Date"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "WeekofYear starting from Tuesday", each Date.WeekOfYear([Date], Day.Tuesday))
in
#"Added Custom"
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hello @Anonymous
this code creates a table with dates starting from beginning of 2018 for 3000 days and adds a new column with the week of the year, using tuesday as starting day
let
Source = List.Dates(#date(2018,1,1), 3000, #duration(1,0,0,0)),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type date}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "Date"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "WeekofYear starting from Tuesday", each Date.WeekOfYear([Date], Day.Tuesday))
in
#"Added Custom"
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hi this is a solution to something I am working on but the output is the day number, how can I convert this into a date? So I end up with a column called week and it will group the data by weeks starting on a Tuesday.