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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Help with cumulative sales of the last 5 weeks ( no dates data)

Hi guys,

 

i want to calculate the cumulative sales of the last 5 for each week. I have 2 tables 1 for sales and 1 for week/month because i wil have other tables like for sales 2018,2017,2016 etc. and those tables will be linked to the week/month for comparative analisys.

 

PS. I dont have a date in the data so measures like this one wont help me 😕

 

Last4weeksSales =
CALCULATE (
    [Sum of Sales Measure],
    DATESINPERIOD ( 'Table'[Date], LASTDATE ( 'Table'[Date] ), -28, DAY )
)

 

FWC.JPGfwc2.JPG

 

Thanks in advance for your help 🙂 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Try like this

 

Last4weeksSales =
  _min_week = max([Week Number]) -4
  _max_week = max([Week Number])
CALCULATE (
    [Sum of Sales Measure],
    all([Week Number]), [Week Number] >= _min_week && [Week Number] <=_max_week
)

 

In place of max, you might require maxx. Also, you need to adjust when the week becomes negative.

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

Try like this

 

Last4weeksSales =
  _min_week = max([Week Number]) -4
  _max_week = max([Week Number])
CALCULATE (
    [Sum of Sales Measure],
    all([Week Number]), [Week Number] >= _min_week && [Week Number] <=_max_week
)

 

In place of max, you might require maxx. Also, you need to adjust when the week becomes negative.

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks a Lot! it worked !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.