cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

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

How to use column name as a variable.

I want to select some rows from a column ( I have a column named as 'RESOLUTION' in the current data table)

This two lines will work:

======================================

dt = Current Data Table();

dt<<Select Where(RESOLUTION > 0.);

======================================

If I define 'RESOLUTION' as another variable, it doesn't work:

============================================

dt = Current Data Table();

colA="RESOLUTION";

dt<<Select Where(column(dt, colA) > 0.);

============================================

This will not select any row.

Could someone kindly tell me how could I do this?

Thanks.

5 REPLIES 5
pmroz
Super User

Re: How to use column name as a variable.

qt,

This will do the trick.

dt = Current Data Table();

colA = "Resolution";

col_expr = "dt << Select Where(:name(\!"" || colA || "\!") > 0.)";

eval(parse(col_expr));

Basically you're creating some dynamic code, and then executing it.

qt
qt
Level I

Re: How to use column name as a variable.

It works!!

Many thanks!

David_Burnham
Super User (Alumni)

Re: How to use column name as a variable.

Alternatively use the AsColumn function:

colA="RESOLUTION";

dt<<Select Where(AsColumn(colA) > 0.)

-Dave
tsl
tsl
Level III

Re: How to use column name as a variable.

One thing to watch with using As Column() is that it seems to be much slower than using the eval( parse(..)) syntax for a large data table.

In my case I had a data table with 390k rows and 17 columns.

Using Eval ( Parse ( .... )) took 67 msec to select the rows I was looking for while using the As Column() syntax took 3,600 msec !  ( using HPTime() to measure )

So while the As Column() syntax is a whole lot more readable in the code, if speed matters, it may not be the best option

jthi
Super User

Re: How to use column name as a variable.

It might make AsColumn() faster if you combine it with Column().

Re: Should you Loop through a data table or use Recode, or use Get Rows Where to change values in a ... 

 

 

-Jarmo

Recommended Articles