How to use a list to select rows with an specific valueHi I am trying to use a list of Names that populate a column to select the matching rows of another column (in another Table) in order to subset the table and generate several different subsets.
Getting the Names/Values from the first column is no problem but I cannot find the correct syntax for the loop.
dt4 = Current Data Table();
uniqueVals = {"2021_file1_T1", "2021_file1_T2"};
tableList= {};
For(i=1, i< N Items(uniqueVals), i++,
dt4 << select where( As Column("Type") == [i] ) );
dt4 << Select Columns (all);
newdt[i] = dt4 << Subset( Selected columns );
Insert Into(tableList, Data Table(newdt[i]));
dt4 << Clear Column Selection();
dt4 << Clear Select();
);// end of ForI think that my basic logic is OK since this code works very well
dt4 << select where( As Column("Type") =="2021_file1_T2");
dt4 << Select Columns(all);
dt4 << Subset (Selected columns);But I cannot figure out how to pass [i] to the "Select Where". Attached is a simplified test table.
I will appreciate any hints/ solution/suggestions.
Data Blending and CleanupRe: How to use a list to select rows with an specific valueHi @txnelson, So close yet so far.... Thank you very much for your help.
Re: How to use a list to select rows with an specific valueYou were pretty close in getting done what you want. Below is my rework of your code. Please note that your tableList list is redundant with the newdt list that you are referencing.
dt4 = Current Data Table();
uniqueVals = {"2021_file1_T1", "2021_file1_T2"};
//tableList = {};
newdt = {};
For( i = 1, i <= N Items( uniqueVals ), i++,
dt4 << select where( As Column( "Type" ) == uniqueVals[i] );
dt4 << Select Columns( all );
newdt[i] = dt4 << Subset( Selected columns );
//Insert Into( tableList, Data Table( newdt[i] ) );
dt4 << Clear Column Selection();
dt4 << Clear Select();
);