Select where with hide and exclude does not work in a for loopHello community,
I want to be able to use the for loop to update row exclusions, but when I use it, all the rows get hidden/excluded. Would appreciate any help.
// This works
dt << select where( :Flag !="");
dt << hide and exclude;
// This does not work
For( i = 1, i <= N Items( hides ), i++,
dt << select where( hides[i] !="");
dt << hide and exclude;
);
// Neither does this
dt << select where( hides[1] !="");
dt << hide and exclude;
I know I am asking a lot of questions, since I do not have formal training on jsl, and I am still learning most of the stuff on the fly while completing a project. Would appreciate any good scripting guide manuals. I have the official one, but it still seems incomplete.
Automation and ScriptingBasic Data Analysis and ModelingData AccessData Blending and CleanupData Exploration and VisualizationRe: Select where with hide and exclude does not work in a for loopWhat does hides contain?
Re: Select where with hide and exclude does not work in a for loopit contains a list of columns that the user selects in a column dialog, so something like
{:Flag, :OZONE}Re: Select where with hide and exclude does not work in a for loopAre you trying to hide and exclude all rows which aren't missing in those columns?
Re: Select where with hide and exclude does not work in a for loopYes indeed. When I run the first 2 lines of code, it works fine, but when I am running the same code, using list items, it hides and excludes the entire data table.
Re: Select where with hide and exclude does not work in a for loopTry adding AsColumn() around your hides[i].
Not directly related to this, but if you have JMP16+ it is usually better to use For Each instead of For
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(4),
Compress File When Saved(1),
New Column("Column 1", Character, "Nominal", Set Values({"a", "", "a", ""})),
New Column("Column 2", Character, "Nominal", Set Values({"", "b", "b", ""}))
);
cols = {:Column 1, :Column 2};
For Each({cur_col}, cols, // if you have JMP16+ usually better to use For Each than for
dt << Select Where(cur_col != "") << Hide and Exclude(1) << Clear Select
);
Re: Select where with hide and exclude does not work in a for loopIs the "Official" scripting guide, the Scripting Guide available under the Help pull down menu?
The code for your script
For( i = 1, i <= N Items( hides ), i++,
dt << select where( hides[i] !="");
dt << hide and exclude;
);
Needs to be changed to
For( i = 1, i <= N Items( hides ), i++,
dt << select where( As Column( dt, hides[i] ) != "" );
dt << hide and exclude;
);