Choose Language Hide Translation Bar
lwx228
Community Trekker

How do I match the data of the first "ID"?

I tried to match the data of the last "ID" by pressing JSL below. How can I change it to match the data of the first "ID"?

 

dt = Open( "$SAMPLE_DATA\Pizza Combined No Choice.jmp" );"
d2 = Open("$SAMPLE_DATA\Pizza Profiles.jmp");
dt<<Update(With(d2),Match Columns(:Crust=:Crust),Add Columns from Update table( :ID));Wait(0);

Achieve the effect shown below,Thanks!

2019-11-28_18-27.png

 

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
ron_horne
Super User

Re: How do I match the data of the first "ID"?

Hi @lwx228 

please have a look at the following solution. it my not be very robust but in this case it may do the trick.

dt = Open( "$SAMPLE_DATA\Pizza Combined No Choice.jmp" );
d2 = Open( "$SAMPLE_DATA\Pizza Profiles.jmp" );
d2 << New Column( "Crustindex",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Formula( If( :Crust != Lag( :Crust, 1 ) | Row() == 1, 1, Lag( :Crustindex, 1 ) + 1 ) )
);
d2:Crustindex << delete formula;
d2 << Sort( By( :Crust, :Crustindex ), Order( Ascending, Descending ), replace table );
Wait( 0 ); dt << Update( With( d2 ), Match Columns( :Crust = :Crust ), Add Columns from Update table( :ID ) );

please let us know if it helps.

Ron

View solution in original post

3 REPLIES 3
ron_horne
Super User

Re: How do I match the data of the first "ID"?

Hi @lwx228 

please have a look at the following solution. it my not be very robust but in this case it may do the trick.

dt = Open( "$SAMPLE_DATA\Pizza Combined No Choice.jmp" );
d2 = Open( "$SAMPLE_DATA\Pizza Profiles.jmp" );
d2 << New Column( "Crustindex",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Formula( If( :Crust != Lag( :Crust, 1 ) | Row() == 1, 1, Lag( :Crustindex, 1 ) + 1 ) )
);
d2:Crustindex << delete formula;
d2 << Sort( By( :Crust, :Crustindex ), Order( Ascending, Descending ), replace table );
Wait( 0 ); dt << Update( With( d2 ), Match Columns( :Crust = :Crust ), Add Columns from Update table( :ID ) );

please let us know if it helps.

Ron

View solution in original post

lwx228
Community Trekker

Re: How do I match the data of the first "ID"?

I see, there is no ready-made method, only through d2 reflexive sorting, and then use the matching method.

Thank you!
0 Kudos
Highlighted
ron_horne
Super User

Re: How do I match the data of the first "ID"?

Personally, if I had big and messy data, I would filter out the rows I do not want from d2 altogether. Only then I would know I have the update I want.