Subscribe Bookmark RSS Feed

selecting two or more keywords from two or more columns using JSL

fr2007

Community Trekker

Joined:

Jul 3, 2012

i need some help in selecting extracting some keywords from few columns and getting entire rows that have the keywords. Forexample, i have the keywords " socket" and "ball". I want to extract these two keywords from column 1 and column 2. A new datasheet should contain all the rows that contain the two keywords :socket" and "ball"

here is my part of code:

rows2=dt<<get rows where(contains(:column 1,"socket");

sheet1=dt<<subset(columns(),rows(rows2));

the above script only takes one keyword "socket" from one column "column1"

could anyone help with this?

2 REPLIES
pmroz

Super User

Joined:

Jun 23, 2011

Use the AND statement (&):

rows2 = dt << get rows where(contains(:column 1,"socket") & contains(:column 2, "ball"));

pmroz

Super User

Joined:

Jun 23, 2011

Use an AND (&) and an OR (|).  Note the judicious use of parentheses.  If this isn't quite what you need you now have the tools (& and |) to build the correct statement.

rows2 = dt << get rows where((contains(:column 1,"socket") & contains(:column 2, "ball")) |

                             (contains(:column 1,"ball")   & contains(:column 2, "socket")));