cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Tooony
Level I

How to ask User select columns then proceed distribution

Hi all, I'm currenly trying to learn the tableau script and want to releiazed one feature.

 

Ask User choose 1 or many cloumn --> proceed distribuiton

 

May I know how to relaized this? 

 

thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to ask User select columns then proceed distribution

This expanded script should show you how to proceed. It allows the user to make two selections in the same dialog box.

 

Names Default To Here( 1 );

dt = Current Data Table();

dialog = New Window( "Select Columns", << Modal,
	Panel Box( "Column Selection",
		Lineup Box( N Col( 2 ),
			Text Box( "Select column for munging" ),
			m col list = Col List Box( All ),
			Text Box( "Select columns for distribution" ),
			y col list = Col List Box( All )
		)
	),
	H List Box(
		Button Box( "OK",
			m col = m col list << Get Selected;
			y col = y col list << Get Selected;
		),
		Button Box( "Cancel" )
	)
);

If( dialog["Button"] == -1,
	Throw( "User cancelled" )
);

Show( m col, y col );

dt << Select Duplicate Rows( Match( :SerialNumber ) );
xx = dt << Get Selected Rows;
If( N Rows( xx ) > 0,
	dt << Delete Dows
);

dt	<< New Column( "Date Code", Numeric, Continuous, Formula( Munger( :Name( "Serial Number" ), 4, 3 ) ) )
	<< New Column( "Vendor",    Numeric, Continuous, Formula( Munger( :Name( "Serial Number" ), 1, 3 ) ) )
	<< New Column( “Config”,    Numeric, Continuous, Formula( Munger( :Name( "Serial Number" ), 12, 5 ) ) );
	
If( N Items( y col ) > 0,
	y expr = Expr( Y() );
	For( i = 1, i <= N Items( y col ), i++,
		Insert Into( y expr, Column( y col[i] ) )
	);
	Eval( Substitute( Expr( dt << Distribution( yyy ) ), Expr( yyy ), Name Expr( y expr ) ) );
);

 

I see no reason in the example that you provided for the column name to change to "batter serial number."

View solution in original post

3 REPLIES 3

Re: How to ask User select columns then proceed distribution

I can't help you with Tableau.

 

A JMP script that might work is the following:

 

Names Default to Here( 1 );

dt = Current Data Table();

dialog = New Window( "Select Columns", << Modal,
	y col list = Col List Box(
		All
	),
	H List Box(
		Button Box( "OK",
			y col = y col list << Get Selected;
		),
		Button Box( "Cancel" )
	)
);

If( dialog["Button"] == -1,
	Throw( "User cancelled" );
);

Show( y col );

If( N Items( y col ) > 0,
	y expr = Expr( Y() );
	For( i = 1, i <= N Items( y col ), i++,
		Insert Into( y expr, Column( y col[i] ) );
	);
	Eval(
		Substitute(
			Expr( dt << Distribution( yyy) ),
			Expr( yyy ), Name Expr( y expr )
		)
	);
);

 

Tooony
Level I

Re: How to ask User select columns then proceed distribution

Hi Mark, great thanks for your help. 

 

I also faced one question want to ask. Nomally I will need proceed a table which use below script and decoding the serial number first to get date code/config and so on.  Due to some reason, the "SerialNumber" name will change to "battery Serial Number" or something else. if also has the way to let user select which column to "Munger" first, then ask user select columns to do the distribution.

 

dt = currentdatatable();
dt <<
Select duplicate rows( Match( :SerialNumber ) );
xx=dt<<get selected rows;
if(n rows(xx)>0,
dt<<delete rows;
);

WAit(2);
NewColumn("Date Code", Numeric, Continuous, Formula(Munger( :Name( "Serial Number" ), 4, 3 )));
WAit(2);
NewColumn("Vendor", Numeric, Continuous, Formula(Munger( :Name( "Serial Number" ), 1, 3 )));
WAit(2);
NewColumn(“Config”, Numeric, Continuous, Formula(Munger( :Name( "Serial Number" ), 12, 5 )));

Re: How to ask User select columns then proceed distribution

This expanded script should show you how to proceed. It allows the user to make two selections in the same dialog box.

 

Names Default To Here( 1 );

dt = Current Data Table();

dialog = New Window( "Select Columns", << Modal,
	Panel Box( "Column Selection",
		Lineup Box( N Col( 2 ),
			Text Box( "Select column for munging" ),
			m col list = Col List Box( All ),
			Text Box( "Select columns for distribution" ),
			y col list = Col List Box( All )
		)
	),
	H List Box(
		Button Box( "OK",
			m col = m col list << Get Selected;
			y col = y col list << Get Selected;
		),
		Button Box( "Cancel" )
	)
);

If( dialog["Button"] == -1,
	Throw( "User cancelled" )
);

Show( m col, y col );

dt << Select Duplicate Rows( Match( :SerialNumber ) );
xx = dt << Get Selected Rows;
If( N Rows( xx ) > 0,
	dt << Delete Dows
);

dt	<< New Column( "Date Code", Numeric, Continuous, Formula( Munger( :Name( "Serial Number" ), 4, 3 ) ) )
	<< New Column( "Vendor",    Numeric, Continuous, Formula( Munger( :Name( "Serial Number" ), 1, 3 ) ) )
	<< New Column( “Config”,    Numeric, Continuous, Formula( Munger( :Name( "Serial Number" ), 12, 5 ) ) );
	
If( N Items( y col ) > 0,
	y expr = Expr( Y() );
	For( i = 1, i <= N Items( y col ), i++,
		Insert Into( y expr, Column( y col[i] ) )
	);
	Eval( Substitute( Expr( dt << Distribution( yyy ) ), Expr( yyy ), Name Expr( y expr ) ) );
);

 

I see no reason in the example that you provided for the column name to change to "batter serial number."