cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
%3CLINGO-SUB%20id%3D%22lingo-sub-628207%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EDiff%C3%A9rence%20de%20d%C3%A9calage%20r%C3%A9glable%26nbsp%3B%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-628207%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJe%20ne%20sais%20pas%20comment%20titrer%20cela%2C%20mais%20voil%C3%A0.%20J'ai%20des%20ensembles%20de%20donn%C3%A9es%20avec%20plusieurs%20points%20temporels%20par%20lot.%20Pour%20chaque%20lot%2C%20je%20souhaite%20calculer%20la%20diff%C3%A9rence%20entre%20les%20r%C3%A9sultats%20%C3%A0%20partir%20du%20point%20temporel%20z%C3%A9ro.%20J'avais%20l'habitude%20de%20comparer%20chaque%20r%C3%A9sultat%20%C3%A0%20la%20colonne%20min%20ou%20max%20(selon%20le%20cas)%2C%20ce%20qui%20fonctionnait%20bien%2C%20mais%20lorsque%20les%20r%C3%A9sultats%20sont%20un%20peu%20instables%2C%20le%20max%20ou%20le%20min%20peut%20se%20produire%20%C3%A0%20un%20autre%20moment%20que%20z%C3%A9ro.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJe%20veux%20la%20diff%C3%A9rence%20(souhait%C3%A9)%20comme%20ci-dessous.%20Existe-t-il%20un%20moyen%20simple%20de%20proc%C3%A9der%20dans%20une%20formule%26nbsp%3B%3F%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%22Ake_0-1683127236504.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Ake_0-1683127236504.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Ake_0-1683127236504.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F52527i61243B9B9175A74B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Ake_0-1683127236504.png%22%20alt%3D%22Ake_0-1683127236504.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Ejmp%2017.1%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-628207%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EOrganisation%20du%20contenu%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPersonnalisation%20de%20masse%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIng%C3%A9nierie%20Qualit%C3%A9%20et%20Proc%C3%A9d%C3%A9s%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPartager%20et%20communiquer%20les%20r%C3%A9sultats%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eles%20fen%C3%AAtres%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-628238%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20Diff%C3%A9rence%20de%20d%C3%A9calage%20r%C3%A9glable%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-628238%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJ'ajoute%20simplement%20quelques%20options%20possibles%20si%20les%20donn%C3%A9es%20ne%20sont%20pas%20toujours%20tri%C3%A9es.%3C%2FP%3E%0A%3CP%3EUtiliser%20des%20calculs%20matriciels%20pour%20obtenir%20les%20indices%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EAs%20Constant(%0A%20times%20%3D%20%3ATime%20%26lt%3B%26lt%3B%20get%20as%20matrix%3B%0A%20batches%20%3D%20%3ABatch%20%26lt%3B%26lt%3B%20get%20as%20matrix%3B%0A)%3B%0A%0Abatch_rows%20%3D%20Loc(batches%2C%20%3ABatch)%3B%0Abatch_first_time_row%20%3D%20batch_rows%5BLoc%20Min(times%5Bbatch_rows%5D)%5D%3B%0A%3AResult%20-%20%3AResult%5Bbatch_first_time_row%5D%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eet%20en%20utilisant%20Col%20Sum%20pour%20obtenir%20la%20valeur%20minimale%20avec%20comparaison%20et%20produit%20(si%20%3ATime%20n'est%20pas%20le%20plus%20petit%20multiplicateur%20est%200).%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3AResult%20-%20Col%20Sum((%3ATime%20%3D%3D%20Col%20Min(%3ATime%2C%20%3ABatch))%20*%20%3AResult%2C%20%3ABatch)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-628237%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20Diff%C3%A9rence%20de%20d%C3%A9calage%20r%C3%A9glable%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-628237%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELe%20moyen%20le%20plus%20simple%20(%C3%A0%20mon%20avis)%20de%20voir%20comment%20cela%20fonctionne%20est%20de%20diviser%20cette%20formule%20en%20trois%20formules%20diff%C3%A9rentes.%3C%2FP%3E%0A%3CP%3ELe%20premier%20(BatchMinRow)%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ECol%20Min(Row()%2C%20%3ABatch)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EDeuxi%C3%A8mement%2C%20en%20utilisant%20le%20BatchMinRow%20(BatchMinVal)%20qui%20vient%20d'%C3%AAtre%20cr%C3%A9%C3%A9%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3AResult%5B%3ABatchMinRow%5D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eet%20enfin%20le%20troisi%C3%A8me%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3AResult%20-%20%3ABatchMinVal%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ecela%20permet%20de%20voir%20beaucoup%20plus%20facilement%20ce%20que%20font%20les%20diff%C3%A9rentes%20parties%20de%20la%20formule%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-628236%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20Diff%C3%A9rence%20de%20d%C3%A9calage%20r%C3%A9glable%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-628236%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EMerci%20pour%20votre%20r%C3%A9ponse%20extr%C3%AAmement%20rapide%20et%20utile%26nbsp%3B!%20Je%20vais%20r%C3%A9fl%C3%A9chir%20%C3%A0%20comment%2C%20mais%20je%20vois%20que%20%C3%A7a%20marche%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-628220%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20Diff%C3%A9rence%20de%20d%C3%A9calage%20r%C3%A9glable%20%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-628220%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESi%20les%20r%C3%A9sultats%20sont%20ordonn%C3%A9s%2C%20vous%20pouvez%20utiliser%20quelque%20chose%20comme%20ceci%26nbsp%3B%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3AResult%20-%20%3AResult%5BCol%20Min(Row()%2C%20%3ABatch)%5D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ECol%20Min(Row()%2C%20%3ABatch)%20obtiendra%20la%20premi%C3%A8re%20ligne%20d'un%20lot%20sp%C3%A9cifique%20et%20nous%20pourrons%20ensuite%20acc%C3%A9der%20%C3%A0%20cette%20ligne%20en%20utilisant%20%3AResult%5Brownr%5D.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jthi_0-1683129377019.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1683129377019.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1683129377019.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F52529iCEB18B68495316F3%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jthi_0-1683129377019.png%22%20alt%3D%22jthi_0-1683129377019.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ESi%20les%20donn%C3%A9es%20ne%20sont%20pas%20toujours%20ordonn%C3%A9es%2C%20ce%20n'est%20pas%20vraiment%20un%20probl%C3%A8me%2C%20mais%20cela%20n%C3%A9cessitera%20une%20formule%20diff%C3%A9rente.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Ake
Ake
Level III

Adjustable Lag Difference?

Don't know how to title this but here goes. I have data sets with several time points per batch. For each batch I want to calculate the difference in results from time point zero. I used to compare each result to column min or max (as suitable) which worked fine, but when results are a bit jumpy, the max or min may happen at another time point than zero.

 

I want the (desired) diff as below. Is there a simple way to do this in a formula? 

 

Ake_0-1683127236504.png

jmp 17.1

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Adjustable Lag Difference?

If the results are ordered, you could use something like this:

:Result - :Result[Col Min(Row(), :Batch)]

Col Min(Row(), :Batch) will get the first row for specific batch and then we can access that row by using :Result[rownr].

jthi_0-1683129377019.png

If the data isn't always ordered it isn't really a problem, but it will require different formula

-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Adjustable Lag Difference?

If the results are ordered, you could use something like this:

:Result - :Result[Col Min(Row(), :Batch)]

Col Min(Row(), :Batch) will get the first row for specific batch and then we can access that row by using :Result[rownr].

jthi_0-1683129377019.png

If the data isn't always ordered it isn't really a problem, but it will require different formula

-Jarmo
Ake
Ake
Level III

Re: Adjustable Lag Difference?

Thanks for extremely fast, and useful, response! I will ponder how, but I see it works!

jthi
Super User

Re: Adjustable Lag Difference?

Easiest way (in my opinion) to see how it works is to divide that formula into three different formulas

First one (BatchMinRow)

Col Min(Row(), :Batch)

Second using the just created BatchMinRow (BatchMinVal)

:Result[:BatchMinRow]

and finally third one

:Result - :BatchMinVal

this makes it much easier to see what the different parts in the formula do

-Jarmo
jthi
Super User

Re: Adjustable Lag Difference?

Just adding few possible options if the data isn't always sorted.

Using matrix calculations to get the indices

 

As Constant(
	times = :Time << get as matrix;
	batches = :Batch << get as matrix;
);

batch_rows = Loc(batches, :Batch);
batch_first_time_row = batch_rows[Loc Min(times[batch_rows])];
:Result - :Result[batch_first_time_row];

and using Col Sum to get the minimum value with comparison and product (if :Time isn't the smallest multiplier is 0).

:Result - Col Sum((:Time == Col Min(:Time, :Batch)) * :Result, :Batch);

 

 

 

-Jarmo

Recommended Articles