Forum Discussion
Week Number from a Custom of Start Month
Hi,
I need to be able to determine week number from our own custom start of month. For instance, Our February, 2020 Fiscal Month started on 26th January, 2020 and will end on 25th Febraury, 2020. March will start on 26th February.
Our week starts on a Tuesday. How do I determine the week number from our Fiscal Start of Month? That is having 28th January to 3rd February being WEEK 1?
Hi gfo
As tested, i can get the results below:
2020 fiscal year start from 2020/1/26,
2020/1/28-2020/2/3 as week2,
Query1: create date table (start_Date as date, end_date as date)=> let duration_days=Duration.Days(end_date-start_Date), Source = List.Dates(start_Date,duration_days,#duration(1,0,0,0)) in Source Query2: Date let Source = #"create date table"(#date(2020, 1, 1), #date(2020, 12, 31)), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "date"}}), #"Inserted Month" = Table.AddColumn(#"Renamed Columns", "Month", each Date.Month(Date.AddDays([date],-25))), #"Added Custom" = Table.AddColumn(#"Inserted Month", "Custom", each Date.AddDays([date],-25)), #"Inserted Week of Year" = Table.AddColumn(#"Added Custom", "Week of Year", each Date.WeekOfYear(Date.AddDays([date],-25),Day.Friday)), #"Removed Columns" = Table.RemoveColumns(#"Inserted Week of Year",{"Custom"}), #"Inserted Year" = Table.AddColumn(#"Removed Columns", "Year", each Date.Year(Date.AddDays([date],-25))) in #"Inserted Year"Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- Jimmy801
Community Champion
Hello gfo
Try this custom function. They will only work for 2020
(dDate as date)=> let DayCustomCalendarWeek = Duration.TotalDays(dDate - #date(2020,1,26)), Weeknumber = Number.RoundUp(DayCustomCalendarWeek/7)+1 in WeeknumberIf 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 - v-juanli-msft
Community Support
Hi gfo
As tested, i can get the results below:
2020 fiscal year start from 2020/1/26,
2020/1/28-2020/2/3 as week2,
Query1: create date table (start_Date as date, end_date as date)=> let duration_days=Duration.Days(end_date-start_Date), Source = List.Dates(start_Date,duration_days,#duration(1,0,0,0)) in Source Query2: Date let Source = #"create date table"(#date(2020, 1, 1), #date(2020, 12, 31)), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "date"}}), #"Inserted Month" = Table.AddColumn(#"Renamed Columns", "Month", each Date.Month(Date.AddDays([date],-25))), #"Added Custom" = Table.AddColumn(#"Inserted Month", "Custom", each Date.AddDays([date],-25)), #"Inserted Week of Year" = Table.AddColumn(#"Added Custom", "Week of Year", each Date.WeekOfYear(Date.AddDays([date],-25),Day.Friday)), #"Removed Columns" = Table.RemoveColumns(#"Inserted Week of Year",{"Custom"}), #"Inserted Year" = Table.AddColumn(#"Removed Columns", "Year", each Date.Year(Date.AddDays([date],-25))) in #"Inserted Year"Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.