Reply
avatar user
Anonymous
Not applicable

Facing issue building last year weekend date

Want to calculate Last Year weekend dates with respect to week number. SO This years and last years weeknd dates should be alligned to respective week number.

pratikm1354_1-1683644191297.png

Below is the excel sheet which is to be replicated exactly in power BI,  but facing errors in Power BI while creating formula for last year weekend column.

pratikm1354_2-1683644997112.png

 

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @Anonymous ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1683774717506.png

(2) We can create a calculated column.

LY Weekend Dates = 
VAR a =
    ADDCOLUMNS (
        CALENDAR (
            DATE ( YEAR ( [date] ) - 1, 1, 1 ),
            DATE ( YEAR ( [date] ), 12, 31 )
        ),
        "WEEKNUM", WEEKNUM ( [Date], 2 ),
        "WEEKDAY", WEEKDAY ( [Date], 2 ),
        "Year", YEAR ( [Date] )
    )
RETURN
    MAXX (
        FILTER (
            a,
            [WEEKNUM] = EARLIER ( 'Table'[WEEKNUM] )
                && [WEEKDAY] = 7
                && [Year]
                    = YEAR ( EARLIER ( 'Table'[date] ) ) - 1
        ),
        [Date]
    )

(3) Then the result is as follows.

vtangjiemsft_1-1683774762333.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

View solution in original post

1 REPLY 1
v-tangjie-msft
Community Support
Community Support

Hi @Anonymous ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1683774717506.png

(2) We can create a calculated column.

LY Weekend Dates = 
VAR a =
    ADDCOLUMNS (
        CALENDAR (
            DATE ( YEAR ( [date] ) - 1, 1, 1 ),
            DATE ( YEAR ( [date] ), 12, 31 )
        ),
        "WEEKNUM", WEEKNUM ( [Date], 2 ),
        "WEEKDAY", WEEKDAY ( [Date], 2 ),
        "Year", YEAR ( [Date] )
    )
RETURN
    MAXX (
        FILTER (
            a,
            [WEEKNUM] = EARLIER ( 'Table'[WEEKNUM] )
                && [WEEKDAY] = 7
                && [Year]
                    = YEAR ( EARLIER ( 'Table'[date] ) ) - 1
        ),
        [Date]
    )

(3) Then the result is as follows.

vtangjiemsft_1-1683774762333.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)