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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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])

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
Super User
Super User

@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!:
Power BI Cookbook Third Edition (Color)

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Kudoed Authors