cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMPĀ® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to use Select Where () with Contains () to find partial matches in data table?

I have a list

myList  = {"Current_I20_", "Voltage_CIB_", "Capacitance_DIFF_", "Resistance_FURR_"};

and a data table with one of columns called Parameter with some row entries as 

Current_I20_Stage2
Voltage_CIB_Stage3
Capacitance_DIFF_corner_Stage1
Resistance_FURR__side_Stage3

Using myList with Contains() to extract the full parameters names from the data table into a list. How to do this via JSL?

For a start, the following is not selecting anything in my data table. Where am I going wrong?

dt<< select where(Contains(mylist, As column (Parameter)));

 

 

When it's too good to be true, it's neither
11 REPLIES 11

Re: How to use Select Where () with Contains () to find partial matches in data table?

Yes, combine multiple conditions with And() to match strings for rows that are not currently hidden or excluded. There is a complete explanation and plenty of examples here.

jthi
Super User

Re: How to use Select Where () with Contains () to find partial matches in data table?

You could use !Excluded() and !Hidden() but Contains() seems to be doing some funny stuff in this case, so you have to manage around that, All() seems to work in this case

Names Default To Here(1);
Clear Log();
dt = New Table("Untitled 2",
	Add Rows(6),
	Compress File When Saved(1),
	New Column("param",
		Character,
		"Nominal",
		Set Values(
			{"Current_I20_Stage2", "Voltage_CIB_Stage3", "Capacitance_DIFF_corner_Stage1",
			"Resistance_FURR__side_Stage3", "a", "b"}
		)
	),
	New Column("Group", Character, "Nominal", Set Values({"A", "B", "C", "D", "E", "F"})),

);

ToHideAndExcludeList = {"A", "D", "F"};
dt << Select Where(Contains(ToHideAndExcludeList, :Group));
sr = dt << Invert Row Selection;
sr << Hide and Exclude;
dt << Clear Select;

my_list = {"Current_I20_", "Voltage_CIB_", "Capacitance_DIFF_", "Resistance_FURR_"};

rows = dt << Get Rows Where(All(Contains(my_list, Word([1 2], :param, "_") || "_")) & !Excluded() & !Hidden());
vals = dt[rows, "param"];

 

Edit:

Or some eval expr

rows = dt << Get Rows Where(Eval(EvalExpr((Contains(my_list, Expr(Word([1 2], :param, "_") || "_"))))) & !Excluded() & !Hidden());
-Jarmo