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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

How to filter data - current week and next 5 weeks (including weeks in next year)

Hi, 

 

I was using this formula below to filter on current week and next 5 weeks but since the coming weeks are in 2023, this formula it's not working properly.. 

 

Any help? 

 

Formula I'm using : 

 

Date_Filter =
VAR next =
    TODAY () + 7
VAR yn =
    YEAR ( next )
VAR yt =
    YEAR ( TODAY () )
VAR weeknumt =
    WEEKNUM ( TODAY () )
VAR weeknun =
    WEEKNUM ( next )
VAR wek =
    WEEKNUM ( Dim_Calendar[Calendar Date] )
RETURN
    IF (
            yn = YEAR ( Dim_Calendar[Calendar Date] )
                && weeknun = wek ||
            yt = YEAR ( Dim_Calendar[Calendar Date] )
                && weeknumt = wek ||
            yt = YEAR ( Dim_Calendar[Calendar Date] )
                && WEEKNUM(TODAY() +14) = wek ||
            yt = YEAR ( Dim_Calendar[Calendar Date] )
                && WEEKNUM(TODAY() + 21) = wek ||
            yt = YEAR ( Dim_Calendar[Calendar Date] )
                && WEEKNUM(TODAY() +28)  = wek||
            yt = YEAR ( Dim_Calendar[Calendar Date] )
                && WEEKNUM(TODAY() +35)  = wek||
            yt = YEAR ( Dim_Calendar[Calendar Date] )
                && WEEKNUM(TODAY() +42)  = wek ,
        "current week & next weeks",
        BLANK ()
    )
1 ACCEPTED SOLUTION
Anonymous
Not applicable

This solution works also ! 

 

Date_filter = VAR FIRST_DATE = SWITCH(WEEKDAY(TODAY(),2),

1,TODAY(),
2,TODAY()-1,
3,TODAY()-2,
4,TODAY()-3,
5,TODAY()-4,
6,TODAY()-5,
7,TODAY()-6
)

VAR LAST_DATE = FIRST_DATE + 42

RETURN

IF(Dim_Calendar[Calendar Date] >= FIRST_DATE && Dim_Calendar[Calendar Date] < LAST_DATE,"Y","N"

)

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

If this is your expected output, try:

vcgaomsft_0-1671791138386.png

 

Date_Filter = 
VAR _weekday = WEEKDAY(TODAY(),2)
VAR _min_date = TODAY()-_weekday+1
VAR _max_date = _min_date+35
VAR _filter = IF('Dim_Calendar'[Calendar Date]>=_min_date&&'Dim_Calendar'[Calendar Date]<_max_date,"current week & next weeks")
RETURN
_filter

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Anonymous
Not applicable

This solution works also ! 

 

Date_filter = VAR FIRST_DATE = SWITCH(WEEKDAY(TODAY(),2),

1,TODAY(),
2,TODAY()-1,
3,TODAY()-2,
4,TODAY()-3,
5,TODAY()-4,
6,TODAY()-5,
7,TODAY()-6
)

VAR LAST_DATE = FIRST_DATE + 42

RETURN

IF(Dim_Calendar[Calendar Date] >= FIRST_DATE && Dim_Calendar[Calendar Date] < LAST_DATE,"Y","N"

)
Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

Please confirm your Dim_Calendar  contains data for 2023?

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Yes, sure! I have data for 2023 and more in my Dim_Calendar table.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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