How to update table after sorting?Hello Everybody,
I have an issue regarding sorting of a table. I wanted to sort table by Date (located in Date1 column) and I am doing that after certain condition is met. However, it does not sort and replace the table EL_summary after sorting. Is there any refreshing necessary? I put also some delay, I thought one need to wait some time. When I am not using replace table(1), the new Table under different name is created and opened (what I don't want) and again data in this table is not sorted. After that, however, data in EL_summary seems to be updated and sorted. I would appreciate for pointing what I am missing. Best regards
Current Data Table( EL_summary );
if( N rows(EL_summary) > 0, EL_summary << sort(by(:name("Date1")), Order( Ascending ), replace table(1)));
wait(1);
Re: How to update table after sorting?Hi, what is the official way to sort a data table via JSL with the option ReplaceTable()?
As discussed before, If there are open Reports, the script crashes with the error message:

... even if the graph doesn't depend of the ordering in the data table:
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 437, 413 ),
Graph Spacing( 4 ),
Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
dt<< Sort( By( :height ), Replace Table, Order( Ascending ));
How about replacing the text with something like:
Unfortunately, in the current version of Jmp, there is no chance to sort a table with open reports.
Jmp cannot replace the existing table because there is some chance ... hm, you know, report windows might depend on the previous ordering. Unfortunately, there is no option to check that - and there is no option to ignore it. So the Script will stop here.

Re: How to update table after sorting?Ok, I manage to hide the new data table. That data table was the current data table so I disabled its visibility by using
Current Data Table() << ShowWindow( 0 );
Thank you all for support. Best regards.
Re: How to update table after sorting?You can handle this in a couple of different ways.
The output that is keeping the data table from sorting, can be moved to a Journal for display, and the original display can be then deleted, which will allow the sorting to then take place.
Yo can also create a new data table that is either invisible, or private, which will keep the new data table from being displayed. Look for the Invisible, or Private options in subsetting the data table in the Scripting Index.
Re: How to update table after sorting?Hello, thank you for suggestions!
I created one GUI and sorting needs to be done after I select one item from the List Box. After that certain pictures needs to be displayed in this GUI in the order based on the sorted values. Actually, JMP is not providing any useful log information indicating source of problem. Is there any way to hide or make invisible the new (and undesired) datatable that is created after sorting? That would be some workaround.
Re: How to update table after sorting?Hi,
This code performed as expected when there are no graphs open:
Untitled = data table("Untitled.jmp");
if( N rows(Untitled) > 0, Untitled << sort(by(:name("Column 1")), Order( Ascending ), replace table(1)));
But the sort fails to work if you have any graphs open,
Untitled <<DISTRIBUTION> 0, Untitled << sort(by(:name("Column 1")), Order( Descending ), replace table(1)));
</DISTRIBUTION>
Look at the log file and we see:
JMP cannot replace the existing table because there are report windows that depend on the previous ordering.
But if we remove replace table, it will execute without error but it will launch a new datatable with the sorted rows which is not desired.
Untitled <<DISTRIBUTION> 0, Untitled << sort(by(:name("Column 1")), Order( Descending )));</DISTRIBUTION>
So you can check the log file to see if it is informative. If you have any dependent graphs or tables open, maybe you need to rethink the logic of the script. Is it possible to re-sort before making dependent tables and graphs, for example.
Re: How to update table after sorting?is your data table inked to a previous table, so it can not be changed?