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
rschaudhr
Resolver II
Resolver II

Calculated Column sum last 60 days

Here is the data below:

 

DateIndexDataCalculated column - Data_Index
2018011100 
2018022200 
201803350350
201805450300
2018065400500
201809625475

 

So I have the above table. I have date, index and data column. I want to create a calculated column with takes the values from index and data and add the last 3 day (including the current row). So for example, index 3, the calculated column would have 350 which is (50 [index 3] + 200[index 2] + 100[index 3]). 

Is there any way to accomplish this?

Thank you

1 ACCEPTED SOLUTION

@amitchandak  and @Greg_Deckler 

 

The code is working. Thank you both!

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@rschaudhr , a new column like

sumx(filter(Table, [index] <=earlier([index]) && [index] >=earlier([index])-2),[Data])

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

@amitchandak  and @Greg_Deckler 

 

The code is working. Thank you both!

Greg_Deckler
Community Champion
Community Champion

@rschaudhr So, maybe:

Column =
  VAR __Min = [Date]-60
RETURN
  SUMX(FILTER('Table',[Date]<=EARLIER([Date]) && [Date]>=__Min),[Date])


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 Thanks for the code. However, it is adding the dates not the data. I will see if I can modify it.

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.