- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Column name as variables
Hi there,
I have a question related to the column name convention.
For example, I have a table contains the ages of students from several grades.
age_grade1 | age_grade2 | age_grade3 | age_grade4 | age_grade5 | age_grade6 | age_grade7 |
---|---|---|---|---|---|---|
I like to define a parameter, so I can use "for" loop to do some data processing.
1: only select the non-empty rows.
Parameter = "age_grade1" ;
dtRaw << Select Where( Is Missing( Parameter ) );
however, it won't do anything.
2. select students age in some range.
Parameter = "age_grade1";
dtRaw = select where (Parameter > 7);
it is not working either.
Please help me figure this out. What is the right syntax for the column name?
Thanks,
Shasha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Column name as variables
You need to supply a column reference in this context. Also don't use parameter as a variable name - that's a JSL function. If the word(s) turn blue in the editor then it means that it's a function.
This code works. Note the use of as column for the column reference.
dtraw = current data table();
col_name = "age_grade1" ;
dtRaw << Select Where( Is Missing( as column(dtraw, col_name) ) );
dtRaw << select where (as column(dtraw, col_name) > 7);