cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
shiguelita
Level I

Link Between two tables

I have one data table, and I want to create another data table, but with link between them.

I want that second table update, when I insert data (more rows) in the first table.

what I want to do is have fixed columns and when I include new rows in first table, this rows need to be included in the second table (linked table).

I used Subset to do this, but when I saved and closed the table, the link was lost. Do you know if exist other way to do this?

All those tables will be included in a Journal. I also tried, after that I created the subset table, I used the command in journal “Add Windows Reference”, and the JMP showed me the warning: "Unable to make script for TABLE'S NAME"

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Link Between two tables

Hi,

You could use Subscribe() to run a script when rows are added to the main table.  The following simple example will add the same number of rows to the second smaller table when rows are added to the main Big Class table.


dt = Open( "$SAMPLE_DATA/Big Class.jmp" );


dt2 = New Table( "test" );



addRowsFn = Function( {a, b, insert},


  dtname = (a << Get Name());


  Print( dtname );


  Print( b );


  Print( insert );


  dt2 << Add Rows(b);


);



dt << subscribe( "Test Add", onAddRows( addRowsFn, 3 ) );


More information about subscribing to data tables and other types of subscriptions can be found in the Advanced Data Table Scripting section of the online documentation.

I hope that helps!

Wendy

Wendy

View solution in original post

3 REPLIES 3
jvillaumie
Level III

Re: Link Between two tables

You could create a script to update your first table and re-create the second one again, and send to the journal. It would be like an update.

It wouldn't link the second table to the first, though, just make a new, updated version of it.

I attached a table ("The table that gets updated") with a script to do this as an example. Just:

- create a new table

- add some text in a few rows of column1 for that new table (your new rows. I assumed the new rows would come from a separate table)

- call the new table "the update"

Then run the script "Update table, take subset and create journal" in "The table that gets updated".

It will update the first table with the new rows, creating a brand new table, then take a subset of the brand new table. Each step gets sent to the journal.

It should be easy to adapt the general idea of the script to your specific needs (just edit the script to see what it does).

Re: Link Between two tables

Hi,

You could use Subscribe() to run a script when rows are added to the main table.  The following simple example will add the same number of rows to the second smaller table when rows are added to the main Big Class table.


dt = Open( "$SAMPLE_DATA/Big Class.jmp" );


dt2 = New Table( "test" );



addRowsFn = Function( {a, b, insert},


  dtname = (a << Get Name());


  Print( dtname );


  Print( b );


  Print( insert );


  dt2 << Add Rows(b);


);



dt << subscribe( "Test Add", onAddRows( addRowsFn, 3 ) );


More information about subscribing to data tables and other types of subscriptions can be found in the Advanced Data Table Scripting section of the online documentation.

I hope that helps!

Wendy

Wendy
shiguelita
Level I

Re: Link Between two tables

Wendy,

Thank you for your help, sorry for late too.

I tried to do this script, but when I save the  new table ("test") and close, when I open it again, and I update the main table, the second dont update anymore.

I'm new in JMP, but i'm studing scripts now, so i will try this method with another things.

Thank you again!