cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Week Number from a Custom of Start Month

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,

Capture8.JPG

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.

View solution in original post

2 REPLIES 2
Highlighted
Super User I
Super User I

Re: Week Number from a Custom of Start Month

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
        Weeknumber

 

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

Highlighted
Community Support
Community Support

Re: Week Number from a Custom of Start Month

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,

Capture8.JPG

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.

View solution in original post

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021