cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

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

Return "True" or "False" if multiple columns contain string

Hi,

 

I would like to return "False" if any column data contains "hello" else return a "True"

 

kuanaunwei_0-1648740670624.png

 

I am only able to process 1 column with if, any ideas?

10 REPLIES 10
jthi
Super User

Re: Return "True" or "False" if multiple columns contain string

I assume this is what you are looking for

jthi_0-1742976340359.png

You have already been basically provided answer for this, pick "correct" "formula" (these do not evaluate dynamically) and add additional check for "hi"

 

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(3),
	New Column("Column 1", Character, "Nominal", Set Values({"hello", "bye", "bye"})),
	New Column("Column 2", Character, "Nominal", Set Values({"hello", "bye", "bye"})),
	New Column("Column 3", Character, "Nominal", Set Values({"hello", "hello", "bye"})),
	New Column("Column 4", Character, "Nominal", Set Values({"hello", "a hello a", "bye"})),
	New Column("Column 5", Character, "Nominal", Set Values({"hello", "bye", "bye"}), Set Display Width(75)),
	New Column("Column 6", Character, "Nominal", Set Values({"hello hello hi", "hi hi hi hi", "bye"}))
);

dt << new column("C", numeric, continuous, formula(
	If(Row() == 1,
		dt = Current Data Table();
		rangelow = 1;
		rangehigh = 6;
	);
	res = Filter Each({val}, dt[Row(), Index(rangelow, rangehigh)], Contains(val, "hello") | Contains(val, "hi"));
	N Items(res);
));

 

 

-Jarmo

Recommended Articles