cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
twillkickers
Level III

User Defined Function with Specified Column Name (JSL)

I am trying to create a user defined function where you can specify a column name as one of the inputs. For example, I would like to use the below code to create a function that selects rows where the specified "ColumnName" equals the input "Value":

TestFunction = Function( {TableName, ColumnName, Value}, {},
TableName << Select where(:ColumnName == Value);
);

However, when I try and run this function, I get the following error:

Name Unresolved: ColumnName{1} in access or evaluation of 'ColumnName' , :ColumnName/*###*/

What am I doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: User Defined Function with Specified Column Name (JSL)

Here is a script that will accomplish what you need.  It uses a pointer to the data table in the first example, and uses an actual table name in the second example

names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");


TestFunction = Function( {TableName, ColumnName, Value}, {},
TableName << Select where(as column(ColumnName) == Value);
);

testfunction(dt,"age",13);
names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");


TestFunction = Function( {TableName, ColumnName, Value}, {},
data table(TableName) << Select where(as column(ColumnName) == Value);
);

testfunction("Big Class","age",13);
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: User Defined Function with Specified Column Name (JSL)

Here is a script that will accomplish what you need.  It uses a pointer to the data table in the first example, and uses an actual table name in the second example

names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");


TestFunction = Function( {TableName, ColumnName, Value}, {},
TableName << Select where(as column(ColumnName) == Value);
);

testfunction(dt,"age",13);
names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");


TestFunction = Function( {TableName, ColumnName, Value}, {},
data table(TableName) << Select where(as column(ColumnName) == Value);
);

testfunction("Big Class","age",13);
Jim

Recommended Articles