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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Praj
Helper I
Helper I

Get last 6 weeks and next 6 weeks data from current date

Hello Everyone,

 

I have a huge dataset in a table "Raw" and I am looking create a new table which gives me the data from last 6 weeks and next 6 weeks from current day.

I did write the below code but I am just getting partial rows and not the entire output I am expecting. Can anyone suggest the most efficient approach for this problem.

 

Last 6 Weeks and Next 6 Weeks = 
VAR CurrentDate = TODAY()
VAR MinDate = MIN(Raw_Salesforce[Close_Date])
VAR MaxDate = MAX(Raw_Salesforce[Close_Date])
RETURN
    FILTER(
        'Raw_Salesforce',
        Raw_Salesforce[Close_Date] >= DATEADD(Raw_Salesforce[Close_Date], -42, DAY) &&
        Raw_Salesforce[Close_Date] <= DATEADD(Raw_Salesforce[Close_Date], 42, DAY) && 
        Raw_Salesforce[Close_Date]  >= IF(CurrentDate > MaxDate, MaxDate, CurrentDate) - 42 &&
        Raw_Salesforce[Close_Date]  <= IF(CurrentDate < MinDate, MinDate, CurrentDate) + 42 

    )



Thanks in advance!

Cheers,

Praj

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Praj 

try like:

Last 6 Weeks and Next 6 Weeks =
    FILTER(
        Raw_Salesforce,
        Raw_Salesforce[Close_Date]>=TODAY()-42
            &&Raw_Salesforce[Close_Date]<=TODAY()+42
    )

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @Praj 

try like:

Last 6 Weeks and Next 6 Weeks =
    FILTER(
        Raw_Salesforce,
        Raw_Salesforce[Close_Date]>=TODAY()-42
            &&Raw_Salesforce[Close_Date]<=TODAY()+42
    )

Helpful resources

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