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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Measure displaying last week sum

What would be the easiest way to create a measure which calculates the sum of a metric for the last week? 

1 ACCEPTED SOLUTION
edhans
Super User
Super User

As long as you have a date table, there are probably 10 different ways to do this. One such way is this function:

Last Week Sales = 
CALCULATE(
    [Total Sales],
    DATESINPERIOD('Calendar'[Date],TODAY(),-7,DAY)
)

If you wanted the last calendar week, then you'd need the week number in your date table (the WEEKNUM() function will do this, or you could generate in Power Query with Date.WeekOfYear([Date]), but then use this function:


Last Calendar Week Sales = 
CALCULATE(
    [Total Sales],
    'Calendar'[Week Number] = WEEKNUM(TODAY(),1) -1
)

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

5 REPLIES 5
edhans
Super User
Super User

As long as you have a date table, there are probably 10 different ways to do this. One such way is this function:

Last Week Sales = 
CALCULATE(
    [Total Sales],
    DATESINPERIOD('Calendar'[Date],TODAY(),-7,DAY)
)

If you wanted the last calendar week, then you'd need the week number in your date table (the WEEKNUM() function will do this, or you could generate in Power Query with Date.WeekOfYear([Date]), but then use this function:


Last Calendar Week Sales = 
CALCULATE(
    [Total Sales],
    'Calendar'[Week Number] = WEEKNUM(TODAY(),1) -1
)

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Thanks! In my case, I have orders in weeks like in week 3, week 5, week 6, week 8... 

 

Could you guide me how we can sum the previous week orders in this irregular periods? 

 

Thanks in advance.

Anonymous
Not applicable

Thanks, This is really helpful.

Anonymous
Not applicable

HI there @edhans , 

 

I'm hoping you might be able to figure out why my weekly measures aren't working? 

 

I'm trying to get 'last week', 'week prior to last' and also YTD functions for average eng rate & total engagement metrics. 

 

Below is the file link with my measures that are giving me 'blank'

https://www.dropbox.com/s/85v0wkkw4ez7w9d/Example%20file.pbix?dl=0

 

Thank you so much!

Sonia

TomMartens
Super User
Super User

Hey,

 

the easiest way is to create a separate date table.

 

For a start read this post, that describes a lot of common patterns regarding through time in DAX:

https://www.daxpatterns.com/time-patterns/

 

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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