Many ways to do this. I would calculate how many times type appears in ID and if it is the same amount as ID appears in data, then you know it is the only type.
Summary with formula:
Names Default To Here(1);
dt = New Table("From",
Add Rows(8),
New Column("ID", Numeric, "Nominal", Format("Best", 12), Set Values([1, 1, 1, 2, 2, 3, 3, 3])),
New Column("type", Character(16), "Nominal", Set Values({"A", "A", "B", "A", "A", "B", "B", "B"}))
);
dt_summary = dt << Summary(
Output table("To"),
Group(:ID),
N(:type),
Subgroup(:type),
Freq("None"),
Weight("None"),
statistics column name format("column"),
Link to original data table(0)
);
dt_summary << New Column("type2", Character, "Nominal",
<< Set Each Value(
If(:"type, A"n == 0, "B",
:"type, B"n == 0, "A",
"C"
)
)
);
And other using Col Sum with Select duplicated rows:
Names Default To Here(1);
dt = New Table("From",
Add Rows(8),
New Column("ID", Numeric, "Nominal", Format("Best", 12), Set Values([1, 1, 1, 2, 2, 3, 3, 3])),
New Column("type", Character(16), "Nominal", Set Values({"A", "A", "B", "A", "A", "B", "B", "B"}))
);
dt << New Column("type2", Character, Nomimal, Formula(
If(Col Sum(1, :ID) == Col Sum(1, :ID, :type),
:type,
"C"
)
));
wait(1);
dt:type2 << Delete Formula;
wait(1);
dt << Select Duplicate Rows(Match(:ID, :type2));
wait(1);
dt << Delete Rows;
See Scripting Index for more information about the functions especially Col Sum.
-Jarmo