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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Tlotly
Helper V
Helper V

Set calendar to start on a Sunday

Good day

 

I created  CalendarAuto and from there created Weekstart which looks right. Currently when I select WeekStart of 28 Feb 2022, the week starts from Monday to Sunday (28 Feb - 06 March) which I don't want. 

DAX for WeekStart:  = 'Calendar'[Date]- WEEKDAY('Calendar'[Date],2)+1

 

So what I want is if my Weekstart is 28 Feb 2022, I need the week to start from 27 Feb - 05 March, meaning Sunday to Monday. How do I achieve this?

 

Below is the DAX for the calendar:

Calendar =

--Inputs--
VAR WeekStartsOn = "Sun"
VAR FiscalStartMonth = 7

--NOTE: Calendar week starts from Sunday

--Calculation--
RETURN
ADDCOLUMNS (
CALENDARAUTO ( ),
"MIndex", MONTH ( [Date] ),
"FiscalMIndex", MONTH ( EDATE ( [Date], - FiscalStartMonth + 1 ) ),
"CalMonth", FORMAT ( [Date], "mmm" ),
"CalQtr", "Q"
& CEILING ( MONTH ( [Date] ), FiscalStartMonth - 1 ) / ( FiscalStartMonth - 1 ),
"CalYear", YEAR ( [Date] ),
"Fiscal Week",
VAR FiscalFirstDay =
IF (
MONTH ( [Date] ) < FiscalStartMonth,
DATE ( YEAR ( [Date] ) - 1, FiscalStartMonth, 1 ),
DATE ( YEAR ( [Date] ), FiscalStartMonth, 1 )
)
VAR FilteredTableCount =
COUNTROWS (
FILTER (
SELECTCOLUMNS ( GENERATESERIES ( FiscalFirstDay, [Date] ), "Dates", [Value] ),
FORMAT ( [Dates], "ddd" ) = WeekStartsOn
)
)
VAR WeekNos =
IF (
FORMAT ( FiscalFirstDay, "ddd" ) <> WeekStartsOn,
FilteredTableCount + 1,
FilteredTableCount
)
RETURN
"Week " & WeekNos,
"Fiscal Qtr", "Q"
& CEILING ( MONTH ( EDATE ( [Date], - FiscalStartMonth + 1 ) ), 3 ) / 3,
"Fiscal Trimester", "T"
&"" &CEILING ( MONTH ( EDATE ( [Date], - FiscalStartMonth + 1 ) ), 4 ) / 4,
"Fiscal Year",
VAR CY =
RIGHT ( YEAR ( [Date] ), 2 )
VAR NY =
RIGHT ( YEAR ( [Date] ) + 1, 2 )
VAR PY =
RIGHT ( YEAR ( [Date] ) - 1, 2 )
VAR FinYear =
IF ( MONTH ( [Date] ) > ( FiscalStartMonth - 1 ), YEAR ( [Date] )+1, YEAR ( [Date] ) )
RETURN
FinYear,
"Fiscal YearMonth",
VAR FinYearMonth =
IF ( MONTH ( [Date] ) > ( FiscalStartMonth - 1 ), ((YEAR ( [Date] )+1)* 100) + MONTH ( EDATE ( [Date], - FiscalStartMonth + 1 ) ),
((YEAR ( [Date])* 100)) + MONTH ( EDATE ( [Date], - FiscalStartMonth + 1 ) ))
RETURN
FinYearMonth,
"CalWeekNo", WEEKNUM ( [Date], 2 ),
"Weekend/Working", IF ( WEEKDAY ( [Date], 2 ) > 5, "Weekend", "Working" ),
"Day", FORMAT ( [Date], "ddd" ),
"CustomDate", FORMAT ( [Date], "d/mm" )
)

 

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Tlotly , I given here code for every week day as week start

 

Any Weekday Week - Start From Any day of Week
https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Powe...

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

View solution in original post

2 REPLIES 2
Tlotly
Helper V
Helper V

@amitchandak super amazing. Thank you very much.

amitchandak
Super User
Super User

@Tlotly , I given here code for every week day as week start

 

Any Weekday Week - Start From Any day of Week
https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Powe...

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.