Dear Sait,
The difference is that my first example used a character variable for the grouping variable. Your example uses a numeric variable, which is fine. But it requires a little more handling in the formula. The reason for that is that for numeric values, the Lag() on the first row returns missing and comparing missing to the current row also returns missing. Then, in the 2nd row, a missing value from the first row is being added to the value in the 2nd row, which results in a missing value.
Here's an updated formula that I think should work for the numeric grouping variable case:
If( Row() == 1 | Lag( :Year ) != :Year,
:NetRoomRevenueWithOutVat,
Lag( :CumSumByYear ) + :NetRoomRevenueWithOutVat
)
Let me know if that works for you.
Best,
Michael
Michael Crotty
Principal Statistical Writer
Manager, Statistical Documentation
JMP Development