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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
summer18
Helper III
Helper III

sum of value by specific week numbers

Hi, 

 

I need your help on getting the sum of specific week start and week end.  I tried running total but it's not the expected result.

My chart should look like this whether in table or bar chart:

 

sample01.png

 

It's easy to do this in Excel but could not get it correctly in PowerBI.  Please refer to the details below:

 

sample02.png

 

Here's the link of sample pbix.  

https://drive.google.com/file/d/1KRJfdfqbV88I1Y5eKE2eCvwZSMunhtdr/view?usp=sharing

 

Thanks in advance for your help and sharing your knowledge.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@summer18 - Seems like this should be:

 

Measure =
  VAR __WeekMax = MAX('Table'[Week])
  VAR __WeekMin = __WeekMax - 6
  VAR __Table = FILTER(ALL('Table'),[Week] >= __WeekMin && [Week] <= __WeekMax)
RETURN
  IF(__WeekMin <= 0,BLANK(),SUMX(__Table,[Expenses]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
swise001
Continued Contributor
Continued Contributor

@summer18 
The PBIX file link requires a google sign-in open - please change settings in google to allow anyone with the link to download.  

 

This way - we can use your underlying table design to help you.  

Greg_Deckler
Community Champion
Community Champion

@summer18 - Seems like this should be:

 

Measure =
  VAR __WeekMax = MAX('Table'[Week])
  VAR __WeekMin = __WeekMax - 6
  VAR __Table = FILTER(ALL('Table'),[Week] >= __WeekMin && [Week] <= __WeekMax)
RETURN
  IF(__WeekMin <= 0,BLANK(),SUMX(__Table,[Expenses]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

Thanks for your help. Your formula worked on my issue.  I just added Year in the formula so that the calculation will still be in the same year

 

Measure =
  VAR __WeekMax = MAX('Table'[Week])
  VAR __WeekMin = __WeekMax - 6
  VAR __Table = FILTER(ALL('Table'),

                                  'Table'[Year] = MAX( 'Table'[Year]) &&

[Week] >= __WeekMin && [Week] <= __WeekMax)
RETURN
  IF(__WeekMin <= 0,BLANK(),SUMX(__Table,[Expenses]))
 

@summer18 - Awesome! Glad to hear it. Yes, good call on the year!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@summer18 , refer if my blog on week can help. You can create a week year table if you do not have date. and use that.

 

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

 

Week of choice -https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Powe...

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

Hi @amitchandak I tried the Week Start Date and Week End Date before posting my topic but I could not get it to work correctly on my scenario. Since you provided me on my previous post your blog links, I always refer to them and they're really helpful. Thanks for that

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors