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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
molden2
Frequent Visitor

Sum Previous week selected

Hi,

 

I know this is a common question but I couldn't find a solution that I could apply probably because of the structure of the table.

 

We have a table which has a week rank so where week rank is 1 then its the current week, 2 is last week, 3 the week before and so on.

 

What I'm trying to do is SUM the results of the week selected + 1. So if week rank is 4 on the slicer then I would want to sum the ones where week num is 5

 

This is what I've done but its not working as I expected.

 

Thanks in advance 

 

Test LW Enrolment Rate =
VAR __MEASURE_VALUE =
    CALCULATE(SUM('Prod tbl_Rep_Master_SummaryReport'[Meters]), 'Prod tbl_Rep_Master_SummaryReport'[WeekRank]+1,
    'Prod tbl_Rep_Master_SummaryReport'[Status] IN { "Success" })
 
RETURN
__MEASURE_VALUE
   
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@molden2 Maybe:

Test LW Enrolment Rate =
  VAR __WeekRank = SELECTEDVALUE('Prod tbl_Rep_Master_SummaryReport'[WeekRank])
  VAR __Table = FILTER(ALL('Prod tbl_Rep_Master_SummaryReport'), [WeekRank] = __WeekRank || [WeekRank] = __WeekRank + 1)
  VAR __Result = SUMX(__Table, [Meters])
RETURN
  __Result


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

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@molden2 Maybe:

Test LW Enrolment Rate =
  VAR __WeekRank = SELECTEDVALUE('Prod tbl_Rep_Master_SummaryReport'[WeekRank])
  VAR __Table = FILTER(ALL('Prod tbl_Rep_Master_SummaryReport'), [WeekRank] = __WeekRank || [WeekRank] = __WeekRank + 1)
  VAR __Result = SUMX(__Table, [Meters])
RETURN
  __Result


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...

@Greg_Deckler Thats a great help thank you. It actually summed up 2 weeks together but I just edited it and works perfectly. 

 

Could you explain what the || part of your code is doing though?

 

Thanks again

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.