I am not sure what it is that you want to do with a formula version. That is, what values are you anticipating end up in the new column, but below is my guess on what you might want to do.
FYI, the formula version will not be as efficient as the scripting version, because it will have to execute once for every row.
If( Row() == 1,
dt = Current Data Table();
d1Rows = dt << get rows where( :D1 > 1 );
g1Values = {};
If( N Rows( d1Rows ) > 0,
For( i = 1, i <= N Rows( d1Rows ), i++,
Insert Into( g1Values, dt:G1[d1Rows[i]] )
)
);
);
If( Contains( g1Values, :G1 ),
x = 1;
Row State( Row() ) = Selected State( 1 );
,
x = 0
);
x;
Here is the data table script with the formula applied
New Table( "IfSelRows",
Add Rows( 15 ),
Compress File When Saved( 1 ),
New Column( "G1",
Character( 1 ),
"Nominal",
Set Values(
{"A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "C", "C", "C", "C",
"C"}
),
Set Display Width( 76 )
),
New Column( "D1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0, 0] ),
Set Display Width( 58 )
),
New Column( "Column 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( Row() == 1,
dt = Current Data Table();
d1Rows = dt << get rows where( :D1 > 1 );
g1Values = {};
If( N Rows( d1Rows ) > 0,
For( i = 1, i <= N Rows( d1Rows ), i++,
Insert Into( g1Values, dt:G1[d1Rows[i]] )
)
);
);
If( Contains( g1Values, :G1 ),
x = 1;
Row State( Row() ) = Selected State( 1 );
,
x = 0
);
x;
)
)
)
Jim