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.
Choose Language Hide Translation Bar
AlphaColt356
Level I

Help! How should I set a formula or JSL to implement this calculation?

I want to fill "243" in row 12345 of column NO (column X, Raw5), And push it downwards to fill (column 678910 of NO is filled with "1511")

 

AlphaColt356_0-1737422154449.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Help! How should I set a formula or JSL to implement this calculation?

Here are 2 solutions.

txnelson_0-1737427654978.png

The first solution assumes that all of the data are in sets of 5 rows, so it always assigns values from every 5th row.

If( Mod( Row(), 5 ) == 0,
	Num( :X ),
	Num( :X[(Floor( Row() / 5 ) + 1) * 5] )
);

The second uses the value from the first NO row beyond or equal to the current row number.

As Constant(
	NORows = Current Data Table() << get rows where( :track no == "NO" )
);
val = Num( :X[NORows[1]] );
If( Row() == NORows[1],
	Try( NORows = NORows[Index( 2, Length( NORows ) )] )
);
val;
Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Help! How should I set a formula or JSL to implement this calculation?

Here are 2 solutions.

txnelson_0-1737427654978.png

The first solution assumes that all of the data are in sets of 5 rows, so it always assigns values from every 5th row.

If( Mod( Row(), 5 ) == 0,
	Num( :X ),
	Num( :X[(Floor( Row() / 5 ) + 1) * 5] )
);

The second uses the value from the first NO row beyond or equal to the current row number.

As Constant(
	NORows = Current Data Table() << get rows where( :track no == "NO" )
);
val = Num( :X[NORows[1]] );
If( Row() == NORows[1],
	Try( NORows = NORows[Index( 2, Length( NORows ) )] )
);
val;
Jim
AlphaColt356
Level I

Re: Help! How should I set a formula or JSL to implement this calculation?

Thank you very much

jthi
Super User

Re: Help! How should I set a formula or JSL to implement this calculation?

If you have to do this only once, you can also do this interactively in JMP (Note that JMP isn't able to capture all these steps done here, so it isn't that easy to automate based on JMP created script).

 

First create new column to keep the original order and sort your table descending by it

jthi_0-1737438168258.png

Next fix the X column values to either Numeric OR change NO to Character (I go with the X to numeric).

Then select one NO value from column track no, right click on it and select matching cells

jthi_1-1737438242397.png

Hold Alt and press on X column header to select X columns values which match NO value on track no

jthi_2-1737438276676.png

Press Ctrl + C (or otherwise copy) those values to clipboard, click on NO column header and paste them with Ctrl+V

jthi_3-1737438310994.png

Click on the NO column header to select all the values in it, right click on first value and fill

jthi_4-1737438355850.png

Sort your table again (ascending this time) with the column created in first step and delete the sorting column

jthi_5-1737438405215.png

 

And here is one more formula option using Lag (this assumes you want either characters or that you have numeric X column)

If(Mod(Row(), 5) == 0,
	:X
,
	Lag(:X, -1*(5 - Mod(Row(), 5)))
)
-Jarmo