cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
Minerva
Level I

JSL question of tabulate, sorting, color cells in data table box

Hi Community, My intention is to create multiple table via tabulate, sort the target column in each table from largest to smallest, put them together via new window, and show the first row data in green. Below is how i did it with sample data big class, with some issues I cannot figure out why:

1. the sorting window keeps open and does not really perform the sorting

2. the tabulate platform keeps open

3.  don't know how to color cells after I put them in data table box in a new window

 

Below is my JSL:

 


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

Data Table( "Big Class.jmp" ) << Tabulate();

Local( {obj},
	obj = Data Table( "Big Class.jmp" ) << Tabulate(
		Show Control Panel( 0 ),
		Add Table(
			Column Table( Analysis Columns( :height ) ),
			Row Table( Grouping Columns( :name ) )
		)
	);
	dt1 = obj << Make Into Data Table;
	obj << Close Window;
);

dt1 << Sort(
	By( :"sum(height)"n ),
	Replace Table,
	Order( Descending )
);

Data Table( "Big Class.jmp" ) << Tabulate();

Local( {obj},
	obj = Data Table( "Big Class.jmp" ) << Tabulate(
		Show Control Panel( 0 ),
		Add Table(
			Column Table( Analysis Columns( :weight ) ),
			Row Table( Grouping Columns( :name ) )
		)
	);
	dt2 = obj << Make Into Data Table;
	obj << Close Window;
);


dt2 << Sort(
	By( :"sum(weight)"n ),
	Replace Table,
	Order( Descending )
);

nw = new window("summary", H list box(data table box(dt1), data table box(dt2)));

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JSL question of tabulate, sorting, color cells in data table box

Here is how I was able to get your code to work:

txnelson_0-1743562949270.png

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

//Data Table( "Big Class.jmp" ) << Tabulate();

//Local( {obj},
obj = Data Table( "Big Class.jmp" ) << Tabulate(
	Show Control Panel( 0 ),
	Add Table( Column Table( Analysis Columns( :height ) ), Row Table( Grouping Columns( :name ) ) )
);
dt1 = obj << Make Into Data Table;
obj << Close Window;
//);

dt1 << Sort( By( :"sum(height)"n ), Replace Table, Order( Descending ) );

// Color the cells in row 1
Current Data Table( dt1 );
:name << color cells( "green", 1 );
:"Sum(height)"n << color cells( "green", 1 );


//Data Table( "Big Class.jmp" ) << Tabulate();

Local( {obj},
	obj = Data Table( "Big Class.jmp" ) << Tabulate(
		Show Control Panel( 0 ),
		Add Table( Column Table( Analysis Columns( :weight ) ), Row Table( Grouping Columns( :name ) ) )
	);
	dt2 = obj << Make Into Data Table;
	obj << Close Window;
);

dt2 << Sort( By( :"sum(weight)"n ), Replace Table, Order( Descending ) );

// Color the cells in row 1
Current Data Table( dt2 );
:name << color cells( "green", 1 );
:"sum(weight)"n << color cells( "green", 1 );

// The only way I know to copy cell colors in a data table to a display
// window, is to move the data table with the colored cells to a journal
// Then it can be copied into a display object in a display window.
// I repeat the operation twice in the code below
nw = New Window( "summary", hls = H List Box() );
intJr = New Window( "x", <<journal );
dt1 << journal;
hls << append( intJr );
intJr << close window;
intJr = New Window( "x", <<journal );
dt2 << journal;
hls << append( intJr );
intJr << close window;

Close( dt1, nosave );
Close( dt2, nosave );
Jim

View solution in original post

3 REPLIES 3
jthi
Super User

Re: JSL question of tabulate, sorting, color cells in data table box

Could be issue related namespaces (you are using Local)

Names Default To Here(1);

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

obj = dt << Tabulate(
	Show Control Panel(0),
	Add Table(Column Table(Analysis Columns(:height)), Row Table(Grouping Columns(:name)))
);
dt1 = obj << Make Into Data Table;
obj << Close Window;

dt1 << Sort(By(:"sum(height)"n), Replace Table, Order(Descending));

obj = dt << Tabulate(
	Show Control Panel(0),
	Add Table(Column Table(Analysis Columns(:weight)), Row Table(Grouping Columns(:name)))
);
dt2 = obj << Make Into Data Table;
obj << Close Window;

dt2 << Sort(By(:"sum(weight)"n), Replace Table, Order(Descending));

nw = New Window("summary", H List Box(Data Table Box(dt1), Data Table Box(dt2)));
-Jarmo
Minerva
Level I

Re: JSL question of tabulate, sorting, color cells in data table box

thanks a lot!

i tried but still got the issue of sorting platform open, not really taking action..

if i run the code line by line, it works but don't know why fails when runing the entire code...

 

txnelson
Super User

Re: JSL question of tabulate, sorting, color cells in data table box

Here is how I was able to get your code to work:

txnelson_0-1743562949270.png

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

//Data Table( "Big Class.jmp" ) << Tabulate();

//Local( {obj},
obj = Data Table( "Big Class.jmp" ) << Tabulate(
	Show Control Panel( 0 ),
	Add Table( Column Table( Analysis Columns( :height ) ), Row Table( Grouping Columns( :name ) ) )
);
dt1 = obj << Make Into Data Table;
obj << Close Window;
//);

dt1 << Sort( By( :"sum(height)"n ), Replace Table, Order( Descending ) );

// Color the cells in row 1
Current Data Table( dt1 );
:name << color cells( "green", 1 );
:"Sum(height)"n << color cells( "green", 1 );


//Data Table( "Big Class.jmp" ) << Tabulate();

Local( {obj},
	obj = Data Table( "Big Class.jmp" ) << Tabulate(
		Show Control Panel( 0 ),
		Add Table( Column Table( Analysis Columns( :weight ) ), Row Table( Grouping Columns( :name ) ) )
	);
	dt2 = obj << Make Into Data Table;
	obj << Close Window;
);

dt2 << Sort( By( :"sum(weight)"n ), Replace Table, Order( Descending ) );

// Color the cells in row 1
Current Data Table( dt2 );
:name << color cells( "green", 1 );
:"sum(weight)"n << color cells( "green", 1 );

// The only way I know to copy cell colors in a data table to a display
// window, is to move the data table with the colored cells to a journal
// Then it can be copied into a display object in a display window.
// I repeat the operation twice in the code below
nw = New Window( "summary", hls = H List Box() );
intJr = New Window( "x", <<journal );
dt1 << journal;
hls << append( intJr );
intJr << close window;
intJr = New Window( "x", <<journal );
dt2 << journal;
hls << append( intJr );
intJr << close window;

Close( dt1, nosave );
Close( dt2, nosave );
Jim

Recommended Articles