cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
septon
Level I

How to select individual cell based on condition and insert it?

Hello
I am trying to select an individual cell based on condition and insert it to a column in JSL.
For example:

I have this following table - I want to insert to the first row under column "value"  the "score" value of the second row (11) because:
when looking on the first and second row:

home = home and y=y and x=x+1

Input:

scorehomeyxvalue
10US11 
11US12 
10Canada11 
10US35 

 

Expected:

 

scorehomeyxvalue
10US1111
11US12 
12Canada11 
13US35 

 

Thanks

1 REPLY 1
jthi
Super User

Re: How to select individual cell based on condition and insert it?

Most likely this isn't exactly what you want, but it does solve your example

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(4),
	Compress File When Saved(1),
	New Column("score", Numeric, "Continuous", Format("Best", 12), Set Values([10, 11, 10, 10])),
	New Column("home", Character(16), "Nominal", Set Values({"US", "US", "Canada", "US"})),
	New Column("y", Numeric, "Continuous", Format("Best", 12), Set Values([1, 1, 1, 3])),
	New Column("x", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 1, 5])),
	New Column("value", Numeric, "Nominal", Format("", 16), Set Values([., ., ., .]))
);

Row() = 1;
If(:home == Lag(:home, -1) & :y == Lag(:y, -1) & :x + 1 == Lag(:x, - 1),
	:value[Row()] = Lag(:score, - 1)
);
-Jarmo