cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
scott1588
Level IV

Row Problem

I have a two part question. I am trying to change the value of previous rows in a column based on data in another column and I'm having a couple of problems. In the example below, when the status changes from Status1 to anything else (note green cells), I want to change the value of the cell 6 rows up (red cell).

 

2024-02-19_11-50-48.png

 

The column formula I am using is below.

 

2024-02-19_12-13-53.png

 

As you can see from the table, the script does insert a 99 in Row()-6 but there is also a 99 in Row(). I can't figure out where that last one is coming from.

 

The larger problem I'm trying to solve here is that I want to fill in all cells at and above the status change with 99 (So Row(), Row()-1, Row()-2, ... , Row()-6 all are 99). I tried to use a FOR loop to do this (see second script below) but it does nothing.

 

2024-02-19_12-19-16.png

 

As I'm sure you can tell, I'm pretty ignorant regarding JSL so any assistance on this would be greatly appreciated. Thanks much.

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Row Problem

As I don't have your data table this is just a guess

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(23),
	Compress File When Saved(1),
	New Column("S",
		Character,
		"Nominal",
		Set Values(
			{"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
			"A", "B", "B", "B", "C", "C"}
		)
	)
);

dt << New Column("R", Numeric, Continuous, Formula(
	If(:S == "A" & Lag(:S, -6) != "A",
		99
	, :S == "A",
		Lag(:R)
	);
));

You can use Lag to look for values behind and also forward.

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Row Problem

As I don't have your data table this is just a guess

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(23),
	Compress File When Saved(1),
	New Column("S",
		Character,
		"Nominal",
		Set Values(
			{"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
			"A", "B", "B", "B", "C", "C"}
		)
	)
);

dt << New Column("R", Numeric, Continuous, Formula(
	If(:S == "A" & Lag(:S, -6) != "A",
		99
	, :S == "A",
		Lag(:R)
	);
));

You can use Lag to look for values behind and also forward.

-Jarmo

Re: Row Problem

Thanks, I also want to know it.

scott1588
Level IV

Re: Row Problem

Thanks much for the help! I didn't know you could have negative lags. That's very handy.

Recommended Articles