Hello,
I have the following data and I want to use the Lag function to calculate the difference between each result and the result prior to it (the data table is also attached to this message).
I am using JMP 16.
Currently I'm using the following formula in the "Difference" column:
What I can't figure out is how to get the calculation to "reset" once it gets to Batch B. I realize that even with my current formula, only the difference value in row 16 is incorrect, but still I would know to setup the formula so that it works properly within batches.
Does anyone have any suggestions?
Jeff
change your formula to
If( :"Time Point (months)"n == 0,
.,
:Result - Lag( :Result )
)
change your formula to
If( :"Time Point (months)"n == 0,
.,
:Result - Lag( :Result )
)
If you need such grouped lag operations frequently, you might have a look at
https://marketplace.jmp.com/appdetails/Normalization+GUI in the Marketplace.
It implemented the N-1 in combination with grouping based on @jthi 's approach:
This takes the pain to remember the exact syntax : )
In addition, the Platform handles Excluded rows automatically.
You can also utilize Col Moving Average to get the previous value (Data preparation- substract column data by other column )
:Result- (Col Moving Average(:Result, 1, 1, 0, :Lot Number) * 2 - :Result)
but in your case using something like Jim suggested is most likely better. Also there is Dif function you can use instead of Lag
If( :"Time Point (months)"n == 0,
.,
Dif(:Result, 1)
)