ah.. so you want to calculate col moving average of to include rows but only report it on the last row of each unique ID?
Note that this will calculate the moving average using ALL values in the groups, not just the last values but it will report it on the last line (remove the if-statement to see what it really does)
If(:To Include == "Yes" & Row() == Col Max(Row(), :Unique ID),
Col Moving Average(:"Total (Sum of Stages for each Unique ID)"n, 1, :To Include),
.
)
You can also perform the calculation based only the last rows but the calculation will keep getting slower and more difficult to read
If(:To Include == "Yes" & Row() == Col Max(Row(), :Unique ID),
Col Moving Average(
If(Row() == Col Max(Row(), :Unique ID),
:"Total (Sum of Stages for each Unique ID)"n,
.
),
1,
:To Include
),
.
)
These are easiest to understand when you break it into many separate formulas
-Jarmo