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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
brinky
Helper IV
Helper IV

Exclude current week

Good morning,

 

I'm trying to get all sales for the last eight weeks.
I manged to get the 8 week but would like to exclude the current week

Measure 3 = 
CALCULATE([QTY_Sales],
    FILTER(SalesData,
     DATEDIFF(SalesData[DDate],TODAY(),WEEK) < 8 
    )
)

Any ideas?

 

Thanks in advance.

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

Hi @brinky ,

 

According to the description, you may try this:

Measure = 
CALCULATE (
    [QTY_Sales],
    FILTER (
        'SalesData',
        DATEDIFF ( 'SalesData'[Date], TODAY (), WEEK ) < 8
            && DATEDIFF ( 'SalesData'[Date], TODAY (), WEEK ) >= 1
    )
)

 

If it does not make sense, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Best Regards,
Eyelyn Qin
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

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @brinky ,

 

According to the description, you may try this:

Measure = 
CALCULATE (
    [QTY_Sales],
    FILTER (
        'SalesData',
        DATEDIFF ( 'SalesData'[Date], TODAY (), WEEK ) < 8
            && DATEDIFF ( 'SalesData'[Date], TODAY (), WEEK ) >= 1
    )
)

 

If it does not make sense, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

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

@v-eqin-msft 

 

Thanks works as required.

TomMartens
Super User
Super User

Hey @brinky ,

 

based on my answer in this thread: Solved: Re: Week commencing in DAX - Microsoft Power BI Community

You can create something like this:

some weeks in the past =
var __today = TODAY()
var startOfWeeek = __today  - WEEKDAY( __today , 2 ) + 1 //assuming the week starts with Monday
var endOfWeek = __today + 7 - WEEKDAY( __today , 2 ) 
var numberOfPreviousWeeks = 1
var startOfPrevWeeeks = startOfWeeek - 7 * numberOfPreviousWeeks
var endOfPrevWeek = endOfWeek - 7

return
CALCULATE(
    [Actual Sales]
    , DATESBETWEEN( 'DimDate'[Datekey] , startOfPrevWeeeks , endOfPrevWeek )
)

Hopefully, this provides something to tackle your challenge.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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