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.
Shahid12523
Community Champion
1 year agoSumPrev3Mvs =
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.