How to ask User select columns then proceed distributionHi 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.
Re: How to ask User select columns then proceed distributionThis 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."
Re: How to ask User select columns then proceed distributionHi 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="">0,
dt<<DELETE rows=""></DELETE></GET>
Re: How to ask User select columns then proceed distributionI 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 )
)
);
);