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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Uka
Frequent Visitor

Showing current week and previous week that changes with respect to selected date in the date filter

Hi,

 

Please can you help me to achieve the table below. I wanted to show the data for Current week and Previous week, such that when a date is selected from the date filter, the selected date will appear under current week and previous Friday date will appear under previous week. Please note that our week ends on Fridays. 

 

So, with the table below, the selected date from the Date filter would be 17/11/23. 

Uka_4-1700599474051.png

 

then,  with the table below the selected date from the date filter would be 10/11/23. 

Uka_7-1700599824799.png

 

 

 

Many thanks in advance

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Uka ,

 

I think you can create a Date table to help calculation.

Date = 
VAR _STEP1 =
    ADDCOLUMNS (
        CALENDARAUTO (),
        "Year", YEAR ( [Date] ),
        "Month", MONTH ( [Date] ),
        "WeekDay",
            VAR _WEEKDAY =
                WEEKDAY ( [Date], 2 )
            RETURN
                IF ( _WEEKDAY >= 6, _WEEKDAY - 5, _WEEKDAY + 2 ),
        "DayName", FORMAT ( [Date], "DDDD" )
    )
VAR _STEP2 =
    ADDCOLUMNS (
        _STEP1,
        "WeekStart",
            [Date] - [WeekDay] + 1,
        "WeekEnd",
            [Date] - [WeekDay] + 7
    )
RETURN
    _STEP2

Relationship:

vrzhoumsft_0-1700807272480.png

Measure:

Measure = 
VAR _SELECTDATE =
    SELECTEDVALUE ( 'DimWeekEnd'[WeekEnd] )
VAR _PREWEEKEND = _SELECTDATE - 7
RETURN
    IF (
        MAX ( 'Date'[WeekEnd] ) IN { _SELECTDATE, _PREWEEKEND },
        CALCULATE ( SUM ( 'Table'[Value] ) )
    )

Result is as below.

vrzhoumsft_1-1700807319077.png

vrzhoumsft_2-1700807327234.png

 

Best Regards,
Rico Zhou

 

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

4 REPLIES 4
parry2k
Super User
Super User

@Uka there are tons of videos/blog posts on this, have you done a google search for the solution?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Uka
Frequent Visitor

Hi @parry2k ,

 

Thanks for your reply but I have spent the whole day searching for the solution but could not find any.

All the solutions I found uses no filter in the view as I explained above.

 

I can show the current week and last week without the Dynamic Date Filter requirement.

Please if you can look into it I would appreciate!

 

Thanks

Anonymous
Not applicable

Hi @Uka ,

 

I think you can create a Date table to help calculation.

Date = 
VAR _STEP1 =
    ADDCOLUMNS (
        CALENDARAUTO (),
        "Year", YEAR ( [Date] ),
        "Month", MONTH ( [Date] ),
        "WeekDay",
            VAR _WEEKDAY =
                WEEKDAY ( [Date], 2 )
            RETURN
                IF ( _WEEKDAY >= 6, _WEEKDAY - 5, _WEEKDAY + 2 ),
        "DayName", FORMAT ( [Date], "DDDD" )
    )
VAR _STEP2 =
    ADDCOLUMNS (
        _STEP1,
        "WeekStart",
            [Date] - [WeekDay] + 1,
        "WeekEnd",
            [Date] - [WeekDay] + 7
    )
RETURN
    _STEP2

Relationship:

vrzhoumsft_0-1700807272480.png

Measure:

Measure = 
VAR _SELECTDATE =
    SELECTEDVALUE ( 'DimWeekEnd'[WeekEnd] )
VAR _PREWEEKEND = _SELECTDATE - 7
RETURN
    IF (
        MAX ( 'Date'[WeekEnd] ) IN { _SELECTDATE, _PREWEEKEND },
        CALCULATE ( SUM ( 'Table'[Value] ) )
    )

Result is as below.

vrzhoumsft_1-1700807319077.png

vrzhoumsft_2-1700807327234.png

 

Best Regards,
Rico Zhou

 

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

 

 

Uka
Frequent Visitor

Hi @Anonymous ,

 

Many thanks for this solution.

 

It was very close to what I wanted, so I have modified to suit my situation.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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