- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
get rows where and select where
I'm seeing a weird issue with get rows where when trying to make it dynamic.
dt = Open("$SAMPLE_DATA\Big Class.jmp");
dt << get rows Where(:Sex == "F"); //Works
dt << Get Rows Where(Column("Sex") == "F"); // Doesn't Work
//but ...
col = :Sex; //doesn't work
col = Column("Sex"); //Works
//so trying to do
dt << Get Rows Where (col == "F");
//can't work in any way that I can see
Tried a few different versions. Anyone else getting this? I swear I've done this before. I tried :Name as well but it doesn't like using a variable and doing some type of Eval seems pretty hacky for this.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: get rows where and select where
An empty index appears to be needed to access the data of a column when the current row is implicit. Alternatively As Column() can be applied to a column name (as string) or a variable.
dt << Get Rows Where(Column("Sex")[] == "F"); // Works
col = Column("Sex"); //Works
dt << Get Rows Where(col[] == "F"); // Works
dt << Get Rows Where(As Column(col) == "F"); // Works
dt << Get Rows Where(As Column("sex") == "F"); // Works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: get rows where and select where
I could do
col = Column("Sex")<<Get Values;
Loc(col,"F");
But I still think something within the data table should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: get rows where and select where
An empty index appears to be needed to access the data of a column when the current row is implicit. Alternatively As Column() can be applied to a column name (as string) or a variable.
dt << Get Rows Where(Column("Sex")[] == "F"); // Works
col = Column("Sex"); //Works
dt << Get Rows Where(col[] == "F"); // Works
dt << Get Rows Where(As Column(col) == "F"); // Works
dt << Get Rows Where(As Column("sex") == "F"); // Works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: get rows where and select where
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: get rows where and select where
One more wrinkle. I use strings for the column names, rather than pointers to the column. This works:
dt = Open("$SAMPLE_DATA\Big Class.jmp");
col = "Sex";
srows = dt << get rows Where(as column(dt, col) == "F");
This works too:
srows = dt << get rows Where(as column(col) == "F");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: get rows where and select where
better solution;
dt = Open("$SAMPLE_DATA\Big Class.jmp");
col1="height"; val="61"; val2="95";
srows = dt << get rows Where(char(column(col1)[]) == char(val) );