cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-826802%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHow%20Can%20I%20Get%20The%20Lag%20Function%20to%20%22Reset%22%20With%20Each%20New%20Batch%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-826802%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20the%20following%20data%20and%20I%20want%20to%20use%20the%20Lag%20function%20to%20calculate%20the%20difference%20between%20each%20result%20and%20the%20result%20prior%20to%20it%20(the%20data%20table%20is%20also%20attached%20to%20this%20message).%3C%2FP%3E%3CP%3EI%20am%20using%20JMP%2016.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jgross_2-1736542505146.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_2-1736542505146.png%22%20style%3D%22width%3A%20246px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_2-1736542505146.png%22%20style%3D%22width%3A%20246px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_2-1736542505146.png%22%20style%3D%22width%3A%20246px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_2-1736542505146.png%22%20style%3D%22width%3A%20246px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_2-1736542505146.png%22%20style%3D%22width%3A%20246px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F71841i5F4F56B3D78F55ED%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jgross_2-1736542505146.png%22%20alt%3D%22jgross_2-1736542505146.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ECurrently%20I'm%20using%20the%20following%20formula%20in%20the%20%22Difference%22%20column%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jgross_0-1736542408545.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_0-1736542408545.png%22%20style%3D%22width%3A%20285px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_0-1736542408545.png%22%20style%3D%22width%3A%20285px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_0-1736542408545.png%22%20style%3D%22width%3A%20285px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_0-1736542408545.png%22%20style%3D%22width%3A%20285px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jgross_0-1736542408545.png%22%20style%3D%22width%3A%20285px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F71839i66022B4EC7E17064%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jgross_0-1736542408545.png%22%20alt%3D%22jgross_0-1736542408545.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EWhat%20I%20can't%20figure%20out%20is%20how%20to%20get%20the%20calculation%20to%20%22reset%22%20once%20it%20gets%20to%20Batch%20B.%20I%20realize%20that%20even%20with%20my%20current%20formula%2C%20only%20the%20difference%20value%20in%20row%2016%20is%20incorrect%2C%20but%20still%20I%20would%20know%20to%20setup%20the%20formula%20so%20that%20it%20works%20properly%20within%20batches.%3C%2FP%3E%3CP%3EDoes%20anyone%20have%20any%20suggestions%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJeff%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-826802%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EBasic%20Data%20Analysis%20and%20Modeling%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-826812%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20How%20Can%20I%20Get%20The%20Lag%20Function%20to%20%22Reset%22%20With%20Each%20New%20Batch%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-826812%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Echange%20your%20formula%20to%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EIf(%20%3A%22Time%20Point%20(months)%22n%20%3D%3D%200%2C%0A%09.%2C%0A%09%3AResult%20-%20Lag(%20%3AResult%20)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-826813%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20How%20Can%20I%20Get%20The%20Lag%20Function%20to%20%22Reset%22%20With%20Each%20New%20Batch%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-826813%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EYou%20can%20also%20utilize%20Col%20Moving%20Average%20to%20get%20the%20previous%20value%20(%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FData-preparation-substract-column-data-by-other-column%2Fm-p%2F762950%23U762950%22%20class%3D%22lia-mention-container-editor-message%20lia-img-icon-forum-thread%20lia-fa-icon%20lia-fa-forum%20lia-fa-thread%20lia-fa%22%20target%3D%22_blank%22%3EData%20preparation-%20substract%20column%20data%20by%20other%20column%3C%2FA%3E%26nbsp%3B)%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3AResult-%20(Col%20Moving%20Average(%3AResult%2C%201%2C%201%2C%200%2C%20%3ALot%20Number)%20*%202%20-%20%3AResult)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ebut%20in%20your%20case%20using%20something%20like%20Jim%20suggested%20is%20most%20likely%20better.%20Also%20there%20is%20Dif%20function%20you%20can%20use%20instead%20of%20Lag%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EIf(%20%3A%22Time%20Point%20(months)%22n%20%3D%3D%200%2C%0A%09.%2C%0A%09Dif(%3AResult%2C%201)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-826826%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20How%20Can%20I%20Get%20The%20Lag%20Function%20to%20%22Reset%22%20With%20Each%20New%20Batch%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-826826%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20for%20the%20quick%20replies%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2687%22%20target%3D%22_blank%22%3E%40txnelson%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F14366%22%20target%3D%22_blank%22%3E%40jthi%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMuch%20appreciated!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-826840%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20How%20Can%20I%20Get%20The%20Lag%20Function%20to%20%22Reset%22%20With%20Each%20New%20Batch%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-826840%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIf%20you%20need%20such%20grouped%20%3CFONT%20face%3D%22courier%20new%2Ccourier%22%3Elag%3C%2FFONT%3E%20operations%20frequently%2C%20you%20might%20have%20a%20look%20at%26nbsp%3B%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fmarketplace.jmp.com%2Fappdetails%2FNormalization%2BGUI%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmarketplace.jmp.com%2Fappdetails%2FNormalization%2BGUI%3C%2FA%3E%26nbsp%3Bin%20the%20Marketplace.%3CBR%20%2F%3E%3CBR%20%2F%3EIt%20implemented%20the%20N-1%20in%20combination%20with%20grouping%20based%20on%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F14366%22%20target%3D%22_blank%22%3E%40jthi%3C%2FA%3E%26nbsp%3B's%20approach%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22hogi_0-1736585657173.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22hogi_0-1736585657173.png%22%20style%3D%22width%3A%20269px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F71851iD016D41706668FF7%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22hogi_0-1736585657173.png%22%20alt%3D%22hogi_0-1736585657173.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20takes%20the%20pain%20to%20remember%20the%20exact%20syntax%20%3A%20)%3C%2FP%3E%3CP%3EIn%20addition%2C%20the%20Platform%20handles%20%3CFONT%20face%3D%22courier%20new%2Ccourier%22%3EExcluded%26nbsp%3B%3C%2FFONT%3Erows%20automatically.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
jeff_gross
Level I

How Can I Get The Lag Function to "Reset" With Each New Batch?

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.

 

jgross_2-1736542505146.png

Currently I'm using the following formula in the "Difference" column:

jgross_0-1736542408545.png

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How Can I Get The Lag Function to "Reset" With Each New Batch?

change your formula to

If( :"Time Point (months)"n == 0,
	.,
	:Result - Lag( :Result )
)

 

Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: How Can I Get The Lag Function to "Reset" With Each New Batch?

change your formula to

If( :"Time Point (months)"n == 0,
	.,
	:Result - Lag( :Result )
)

 

Jim
jeff_gross
Level I

Re: How Can I Get The Lag Function to "Reset" With Each New Batch?

Thank you for the quick replies @txnelson @jthi 

Much appreciated!!

hogi
Level XII

Re: How Can I Get The Lag Function to "Reset" With Each New Batch?

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:

hogi_0-1736585657173.png

 

This takes the pain to remember the exact syntax : )

In addition, the Platform handles Excluded rows automatically.

jthi
Super User

Re: How Can I Get The Lag Function to "Reset" With Each New Batch?

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)
)
-Jarmo