Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MH3
Helper V
Helper V

Custom Fiscal Week Calculation

Hi,

 

I have to calculate fiscal week depending upon the Day Number which is Monday it should be the first day of the week.

I used this formula but here it is using Day Name I want to convert into Day Number becuase this logic will work on any condition if there is a language change it will not affect the formula.

New Winter Week = 

--Inputs--
VAR WeekStartsOn = "Mon"
VAR FiscalStartMonth = 11

--Calculation--
VAR FiscalFirstDay = 
    IF(
        MONTH(Dates[Date]) < FiscalStartMonth,
        DATE(
            YEAR(Dates[Date])-1,
            FiscalStartMonth,
            1
        ),
        DATE(
            YEAR(Dates[Date]),
            FiscalStartMonth,
            1
        )
    )
VAR FilteredTableCount = 
    COUNTROWS(
        FILTER(
            SELECTCOLUMNS(
                GENERATESERIES(
                    FiscalFirstDay,
                    Dates[Date]
                ),
                "Dates",
                [Value]
            ),
        FORMAT([Dates],"ddd") = WeekStartsOn
        )
    )
VAR WeekNos = 
    IF(
        FORMAT(FiscalFirstDay,"ddd") <> WeekStartsOn,
        FilteredTableCount + 1,
        FilteredTableCount
    )
RETURN
   WeekNos


WeekStartsOn should be Monday and it should calculate the weeks accordingly till 53 or 52..

I am kinda unable to change the formula like that and Help? 
@amitchandak  

1 REPLY 1
lbendlin
Super User
Super User

I would recommend you use an external calendar table (for example maintained in an Excel file in a Sharepoint)  for anything with fiscal calendars and especially fiscal weeks.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.