Nice, I can use this a lot - so, now I have:
Names Default To Here( 1 );
Try(dt = CurrentDataTable(), stop());
updateLBox = Function( {t},
(t << sib) << setitems( (t << topparent)[listboxbox( 1 )] << getselected )
);
nw = New Window("count unique entries",
<< Type("Modal Dialog"),
Border Box( Left( 10 ), Right( 10 ), bottom( 5 ),
V List Box(
Lineup Box( N Col( 1 ), spacing( 10 ),
// Text Box( "XG Boost Specification" ),
// colistbox only necessary if the script is standalone
H List Box(
Panel Box( "Select Columns", Col List Box( all, nlines( 15 ) ) ),
Panel Box( "Cast Selected Columns into Roles",
Lineup Box( N Col( 2 ),
Button Box("Unique",
<<setfunction( Function( {t}, updateLBox( t ) ) )
),
Cunique = Col List Box( nlines( 2 ), minitems( 1 ) ),
Button Box("By Group",
<<setfunction( Function( {t}, updateLBox( t ) ) )
),
CBy = Col List Box( nlines( 2 ), minitems( 0 ) )
)
)
)
),
spacerbox(size(1,10)),
Button Box( "OK",
<<setfunction(
Function({t}, ColsUnique = Cunique << get items;ColsBy= Cby << get items)
)
),
spacerbox(size(1,10)),
)
)
);
ccs= Expr(Col Cumulative Sum( 1));
for each ({col}, ColsUnique, Insert Into(ccs, Name Expr(As column(col))));
for each ({col}, ColsBy, Insert Into(ccs, Name Expr(As column(col))));
cs = Eval Expr(Col Sum( Expr(Eval Expr(Expr(Name Expr(ccs)) == 1 ))));
for each ({col}, ColsBy, Insert Into(cs, Name Expr(As column(col))));
Eval (Eval Expr(new column ("unique_"|| concat items (ColsUnique,"_"),
Formula(Expr(Name Expr(cs))))))
... available at a single mouse click : )