How do I get rows based on dynamic column selection in JSLIn a JMP script I would like to retrieve the rows matching a certain criteria specified by user. I would like to do something similar to this:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
r = dt << Get Rows Where( :sex == "M" );
Show( r );
Only where the criteria is selected by the user, i.e. the column ("sex") and the target value ("M") should be dynamic. I have tried this without luck:
colname=Column(dt,"sex");
target="M";
r2 = dt << Get Rows Where( colname == target );
show(r2);
What am I doing wrong?
Automation and ScriptingRe: How do I get rows based on dynamic column selection in JSLIssue is with your colname
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
colname = Column(dt, "sex");
target = "M";
r2 = dt << Get Rows Where(As Column(colname) == target);
Show(r2);
or in my opinion better option
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
colname = "sex";
target = "M";
r2 = dt << Get Rows Where(As Column(dt, colname) == target);
Show(r2);
or
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
colname = "sex";
target = "M";
r2 = dt << Get Rows Where(Column(dt, colname)[Row()] == target);
Show(r2);