cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
mlo1
Level IV

value ordering - using JSL to set column properties

Hi

 

I need some scripting advice as there were changes in the column properties from JMP14 to JMP15 regarding the value ordering - introducing "custom order"

The following script works fine in JMP 14 and the result can be seen checking the column properties

Summarize( g = by( :BatchVO ), m = Mean( :name("Timestamp") ) );
// JMP 14 Script for value ordering column "BatchVO" in the Order of the values in column "Timestamp"
:BatchVO << Set Property( "Value Ordering", Eval( g[Rank Index( m )] ) );

mlo1_0-1599138082662.png

The script above works in JMP15 but the result is not visible in the column properties - I guess - due to the new "custom order"

Does anyone knows how to change this to get it working and the result visible in the column properties in JMP15?

The following does not work.

Summarize( g = by( :BatchVO ), m = Mean( :name("Timestamp") ) );

//JMP15 Script
:BatchVO << Set Property( "Value Order",  {Custom Order(Eval( g[Rank Index( m )] ))} );

Any ideas about the correct JSL script for JMP15 and above?

@martindemel 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: value ordering - using JSL to set column properties

The values returned from your Summarize for the "g" variable are returned as character strings, and you are attempting to apply character string values to a numeric column

The code below appears to do what you want

names default to here(1);
Summarize( g = by( :BatchVO ), m = Mean( :name("Timestamp") ) );

for(i=1,i<=nitems(g),i++,
	g[i]=num(g[i])
);

//JMP15 Script
eval(substitute(expr(:BatchVO << Set Property( "Value Order",  {Custom Order(__list__)} );),
expr(__list__), g[Rank Index( m )] ));
Jim

View solution in original post

10 REPLIES 10
txnelson
Super User

Re: value ordering - using JSL to set column properties

The values returned from your Summarize for the "g" variable are returned as character strings, and you are attempting to apply character string values to a numeric column

The code below appears to do what you want

names default to here(1);
Summarize( g = by( :BatchVO ), m = Mean( :name("Timestamp") ) );

for(i=1,i<=nitems(g),i++,
	g[i]=num(g[i])
);

//JMP15 Script
eval(substitute(expr(:BatchVO << Set Property( "Value Order",  {Custom Order(__list__)} );),
expr(__list__), g[Rank Index( m )] ));
Jim
mlo1
Level IV

Re: value ordering - using JSL to set column properties

Thank you very much.
Now it is visible in the column properties menu - great.
JeffO
Level II

Re: value ordering - using JSL to set column properties

How about this one. I'm stuck in Set Property for Spec Limits. Thanks for your help

for (r = 1, r <= N Rows(spectable), r++,
    specname = spectable:Description[r];

   	try(
        dtcol = Column(datatable, specname);
	,
		//write("No data for \!"" || specname|| "\!"");
		Continue()
	);

	//write("Setting spec for \!"" || specname|| "\!"\!r");

    if(not(ismissing(spectable:LSL[r])) | not(ismissing(spectable:USL[r])),
		eval(substitute(expr(dtcol << Set Property("Spec Limits", {LSL(_L), USL(_U), Show Limits(1)})),
			expr(_L), spectable:LSL[r],
			expr(_U), spectable:USL[r]
		));
	);
	
	if(spectable:Units[r] != "",
		eval(substitute(expr(dtcol << Set Property("Units", _U)),
			expr(_U), spectable:Units[r]
		));
	);

	progress = floor((r / N Rows(spectable)) * 100);
   	dlgStatus[FrameBox(1)] << Add Graphics Script({Fill Color("blue"),Rect(0,1,progress,0,1)});
  	wait(0.001);
);
txnelson
Super User

Re: value ordering - using JSL to set column properties

After I commented out your Add Graphics Code line(you did not include the dlgStatus object) your code worked fine for my sample data.  So if it does not work for your code, I suspect there is a mismatch between the name of the columns in your datatable and the description column in your spectable.

Names Default To Here( 1 );
datatable = Open( "$SAMPLE_DATA/big class.jmp" );
spectable = New Table( "specs",
	Add Rows( 2 ),
	New Column( "Description", Character, "Nominal", Set Values( {"height", "weight"} ) ),
	New Column( "LSL", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [52, 61] ) ),
	New Column( "USL", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [70, 175] ) ),
	New Column( "Units", Character, "Nominal", Set Values( {"Inches", "Pounds"} ), Set Display Width( 56 ) )
);

For( r = 1, r <= N Rows( spectable ), r++,
	specname = spectable:Description[r];

	Try(
		dtcol = Column( datatable, specname ), 
		//write("No data for \!"" || specname|| "\!"");
		Continue()
	);

	//write("Setting spec for \!"" || specname|| "\!"\!r");

	If( Not( Is Missing( spectable:LSL[r] ) ) | Not( Is Missing( spectable:USL[r] ) ),
		Eval(
			Substitute(
					Expr(
						dtcol << Set Property( "Spec Limits", {LSL( _L ), USL( _U ), Show Limits( 1 )} )
					),
				Expr( _L ), spectable:LSL[r],
				Expr( _U ), spectable:USL[r]
			)
		)
	);
	
	If( spectable:Units[r] != "",
		Eval( Substitute( Expr( dtcol << Set Property( "Units", _U ) ), Expr( _U ), spectable:Units[r] ) )
	);

	progress = Floor( (r / N Rows( spectable )) * 100 );
	//dlgStatus[FrameBox( 1 )] << Add Graphics Script( {Fill Color( "blue" ), Rect( 0, 1, progress, 0, 1 )} );
	Wait( 0.001 );
);
Jim
JeffO
Level II

Re: value ordering - using JSL to set column properties

Can you help me on this.. it is working fine using V13 but when I upgrade to V15 still prompt an error in setting specs limits.

btw, function of this is to merge 2 or more csv file using 3rd to 5th row as specs. Thanks!

 

txnelson
Super User

Re: value ordering - using JSL to set column properties

What is the error message in the log?
Jim
JeffO
Level II

Re: value ordering - using JSL to set column properties

See attached error message.

 

Error.PNG

txnelson
Super User

Re: value ordering - using JSL to set column properties

The column that you are trying to apply Spec Limits to is of a character data type., You need to change it to numeric.
Jim
SamD
Level II

Re: value ordering - using JSL to set column properties

Hi Jim, I am dealing with similar issue with value ordering format in script; I need to be able to uncheck the customer order and keep it in Row order leve per data table. your help is greatly appreciated

Here is the script portion where I select the columns to to be stacked. 

 

dt = Current Data Table();
dt1 = Data Table( dt ) << Stack(
    columns( :Data Target, :Data1, :Data2, :Data3, :Data4, :Data5, :Best Data, ),
    Source Label Column( "Label" ),
    Stacked Data Column( "Data" ),
    Drop All Other Columns( 1 ), 
);

 

 

When I run my script I get the graph with data sorted alphabetically see pic1 where it shows Best data on the left

I want to have the value order in such way that

1) I could un-select the Customer order box

2) Check the Row Order Levels

this way the graph come the same order in the stack table as pic 2 where the Data target on on far left of the graph.

Thanks

Sam