Forum Discussion
Jyu1994
1 year agoRegular Visitor
Caculated column: Sum previous 3 rows
Dear all, I have this set of data, I need to add a calculated column summing "Mvs" from the previous 3 rows. Any idea? FFor example, the new columns shoul look like this: Index...
- 1 year ago
SumPrev3Mvs =
VAR i = 'YourTable'[Index]
RETURN
CALCULATE(
SUM('YourTable'[Mvs]),
FILTER('YourTable', 'YourTable'[Index] >= i - 3 && 'YourTable'[Index] < i)
)
Adds a column that sums Mvs from the previous 3 rows based on Index.
Works great for sequential data like yours.
Ashish_Mathur
1 year agoSuper User
Hi,
This calculated column formula works
=if(Data[ndex]>=4,CALCULATE(SUM(Data[Mvs]),FILTER(Data,Data[ndex]>=EARLIER(Data[ndex])-3&&Data[ndex]<=EARLIER(Data[ndex])-1)),BLANK())
Hope this helps.