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
Anonymous
Not applicable

Calendar data update

Hi Team,

 

What do I need to do to

a)  Add week to this dax code (Monday - Sunday)

b) Add a piece of code to take account of today's date date_to

 

Calendar =
VAR __MIN =
    DATE ( 2022, 1, 1 )
VAR __MAX =
    DATE ( 2024, 12, 31 )
VAR __BASE =
    CALENDAR ( __MIN, __MAX )
VAR __RESULT =
    ADDCOLUMNS (
        ADDCOLUMNS (
            __BASE,
            "Year", YEAR ( [Date] ),
            "Month Long", FORMAT ( [Date], "mmmm" ),
            "Month Short", FORMAT ( [Date], "mmm" ),
            "Month Number", MONTH ( [Date] ),
            "Month and Year", FORMAT ( [Date], "mmm-yy" ),
            "YYYYMM", FORMAT ( [Date], "YYYYMM" ),
            "Quarter", "Q" & QUARTER ( [Date] ),
            "Day of Week Long", FORMAT ( [Date], "dddd" ),
            "Day of Week Short", FORMAT ( [Date], "ddd" ),
            "Day Sort", WEEKDAY ( [Date], 1 ),
            "Week of Year", WEEKNUM ( [Date] ),
            "Week Ending Saturday",
                VAR __DAY =
                    WEEKDAY ( [Date] ) - 7
                RETURN
                    [Date] - __DAY,
            "Week Ending Wednesday",
                VAR __DAY =
                    WEEKDAY ( [Date] ) - 4
                RETURN
                    [Date] - __DAY
        ),
        "Week Starting Thursday", [Week Ending Wednesday] - 6
    )
RETURN
    __RESULT
1 ACCEPTED SOLUTION
speedramps
Super User
Super User

Simply add this new calculated column to your data table to get the week number

 

 

Week = 
// week starts Monday and ends Sunday
YEAR('Calendar'[Date]) 
& "-" &
FORMAT(WEEKNUM('Calendar'[Date],2),"00")

 

 

Please click "accept solution" and the thumbs up buttons 

View solution in original post

1 REPLY 1
speedramps
Super User
Super User

Simply add this new calculated column to your data table to get the week number

 

 

Week = 
// week starts Monday and ends Sunday
YEAR('Calendar'[Date]) 
& "-" &
FORMAT(WEEKNUM('Calendar'[Date],2),"00")

 

 

Please click "accept solution" and the thumbs up buttons 

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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