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!
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
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
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.