Additional option (I usually do these type of "shifts" using Row() == Col Min(Row()) or Row() == Col Max(Row())).
Names Default To Here(1);
dt = New Table("example 4",
Add Rows(9),
Compress File When Saved(1),
New Column("Y", Character, "Nominal", Set Values({"var1", "var1", "var1", "var2", "var2", "var2", "var3", "var3", "var3"})),
New Column("test", Character, "Nominal", Set Values({"a", "b", "c", "a", "b", "c", "a", "b", "c"})),
New Column("test result", Character, "Nominal", Set Values({"pass", "pass", "fail", "fail", "pass", "fail", "pass", "pass", "pass"}))
);
dt << New Column("Res", Character, Nominal, Formula(
If(Row() != Col Min(Row(), :Y),
"" // not first row fir Y group
, Col Sum(:test result == "pass", :Y) >= 2,
"pass"
, // else
"fail"
)
));
-Jarmo