cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • See how to interactively organize and restructure data for analysis. Register for May 29 webinar, 2pm US ET.

Discussions

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

How to Write Conditional Change Expressions?

//case1
x={"a01","b02","c003"};
dt << select where(:name=="a01"|:name=="b02"|:name=="c003");

//case2
x={"a01","b02","c003","e03"};
dt << select where(:name=="a01"|:name=="b02"|:name=="c003"|:name=="e03");

//case3
x={"a01"};
dt << select where(:name=="a01")

I have a question: as in the three cases of the code below, I now have a list x that changes, so the code for the selection condition also changes, how can I write a piece of code with an expression that takes care of all the x's that change.

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to Write Conditional Change Expressions?

You might have to evaluate the variable

 

Names Default To Here(1);
New Window("Mountains",
	tb = Table Box(
		String Col Box("Mountain", {"K2", "Delphi", "Kilimanjaro", "Grand Teton"}),
		Number Col Box("Elevation (meters)", {8611, 681, 5895, 4199}),
		Plot Col Box("", {8611, 681, 5895, 4199})
	)
);
wait(1);
l = {"K2", "Delphi"};
Eval(EvalExpr(
	tb << Filter Where(Contains(Expr(l), Mountain));	
));
-Jarmo

View solution in original post

6 REPLIES 6
jthi
Super User

Re: How to Write Conditional Change Expressions?

You could use Contains() instead of Or()

Names Default To Here(1);

x = {"a01", "b02", "c003"};

dt << select where(:name == "a01" | :name == "b02" | :name == "c003");
// to
dt << select where(Contains(x, :name));
-Jarmo
lehaofeng
Level V

Re: How to Write Conditional Change Expressions?

Thank you, but the filter where in the tablebox only works like this.For example:                                                              tablebox << filter where(contains(x,colname), will report an error

jthi
Super User

Re: How to Write Conditional Change Expressions?

Few questions:

  • Where are you getting the x list?
  • What are you trying to filter?
  • What is triggering the action to filter?
-Jarmo
lehaofeng
Level V

Re: How to Write Conditional Change Expressions?

1. x from a listbox
2. the value of a column in the tablebox
3. through the listbox selected elements, automatically change the tablebox table content, because the table there is a row with a buttonbox, so still want to achieve through filterwhere

jthi
Super User

Re: How to Write Conditional Change Expressions?

You might have to evaluate the variable

 

Names Default To Here(1);
New Window("Mountains",
	tb = Table Box(
		String Col Box("Mountain", {"K2", "Delphi", "Kilimanjaro", "Grand Teton"}),
		Number Col Box("Elevation (meters)", {8611, 681, 5895, 4199}),
		Plot Col Box("", {8611, 681, 5895, 4199})
	)
);
wait(1);
l = {"K2", "Delphi"};
Eval(EvalExpr(
	tb << Filter Where(Contains(Expr(l), Mountain));	
));
-Jarmo
lehaofeng
Level V

Re: How to Write Conditional Change Expressions?

I can't believe that's the reason, learning, thanks.

Recommended Articles