No idea if this will work in all cases, but it does work with the provided example data:
If(Col Cumulative Sum(1, :Customer_ID) > Col Number(:Value, :Customer_ID) - 1,
Lag(Col Moving Average(:Value, 1, 0, 2, 0, :Customer_ID), 1),
If(Modulo(Col Cumulative Sum(1, :Customer_ID), 3) == 1,
Col Moving Average(:Value, 1, 0, 2, 0, :Customer_ID),
.
)
)
Check what each of the functions/formulas do from scripting index / scripting guide while checking selected subexpression result from formula editor to understand what it is doing as it is quite messy:
-Jarmo