Forum Discussion

Praj's avatar
Praj
Icon for Helper I rankHelper I
3 years ago
Solved

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

  • 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
        )

1 Reply

  • 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
        )