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
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
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.