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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
billyrich83
Frequent Visitor

Help required

Hi all I have the below calculation for fiscal week numbers, however it start the fiscal canlendar to start on the 1st April each year and I need it to start on the 1st Monday in April each year. 

 

Can anyone suggest how to change this to get the right outcome? 

Fiscal Week = 
--Inputs--
VAR WeekStartsOn = "mon"
VAR FiscalStartMonth = 4

--Calculation--
VAR FiscalFirstDay = 
    IF(
        MONTH('Date Table'[Date]) < FiscalStartMonth,
        DATE(
            YEAR('Date Table'[Date])-1,
            FiscalStartMonth,
            1
        ),
        DATE(
            YEAR('Date Table'[Date]),
            FiscalStartMonth,
            1
        )
    )
VAR FilteredTableCount = 
    COUNTROWS(
        FILTER(
            SELECTCOLUMNS(
                GENERATESERIES(
                    FiscalFirstDay,
                    'Date Table'[Date]
                ),
                "Dates",
                [Value]
            ),
        FORMAT([Dates],"ddd") = WeekStartsOn
        )
    )
VAR WeekNos = 
    IF(
        FORMAT(FiscalFirstDay,"ddd") <> WeekStartsOn,
        FilteredTableCount + 1,
        FilteredTableCount
    )
RETURN
    "Week " & WeekNos
5 REPLIES 5
v-xiaotang
Community Support
Community Support

Hi @billyrich83 

Try this, change the value in QUOTIENT to 2

vxiaotang_0-1644470369778.png

Have you solved this question? If you have solved the question, you can accept the answer helpful as the solution or share you method and accept it as solution, thanks for your contribution to improve Power BI.

If you need more help, please let me know.

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Thejeswar
Super User
Super User

Hi @billyrich83 ,
I just modified a little in your code and it worked

Create a new column as below

Start of Week = ('Date'[Date]+-1*WEEKDAY('Date'[Date],2)) + 1

 

Modified the DAX that you shared as follows

FiscalWeek = 
--Inputs--
VAR WeekStartsOn = "mon"
VAR FiscalStartMonth = 4

--Calculation--
VAR FiscalFirstDay = 
    IF(
        MONTH('Date'[Date]) < FiscalStartMonth,
        DATE(
            YEAR('Date'[Date])-1,
            FiscalStartMonth,
            1
        ),
        DATE(
            YEAR('Date'[Date]),
            FiscalStartMonth,
            1
        )
    )
VAR FilteredTableCount = 
    COUNTROWS(
            SELECTCOLUMNS(
                GENERATESERIES(
                    FiscalFirstDay,
                    'Date'[Date]
                ),
                "Dates",
                [Value]
            )
    )
VAR WeekNos = 
            QUOTIENT(FilteredTableCount+1, 7)
RETURN
    "Week " & WeekNos

 

 

Hi, 

 

Thanks for this, 1 small issue it's showing the first dayte as zero and I'm now a day behind in the calculation is there a way to fix this? it might be something I've done. 

 

Screenshot 2022-01-21 100221.png

When I checked the code, found that the hard coding that you have done works fine for one year (probably because you have hard coded based on that year) while it does not work for the other year. Have been busy since then. Hence unable to look into this further. May be someone else can get to help you with this.

amitchandak
Super User
Super User

@billyrich83 , Try these new columns

 

Start Of year = if(month([Date]) <4, date(year([Date])-1,4,1), date(year([Date])-1,4,1))


Start of Week = 'Date'[Date]+-1*WEEKDAY('Date'[Date]

 

FY Start of Week = minx(filter('Date', [Start of Week] >= [Start Of year]), [Start of Week])

 

FY Week No = quotient(datediff([FY Start of Week], [Date], day),7) +1

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors