Having this table:
New Table( "test table",
Add Rows( 9 ),
New Column( "By column",
Character( 1 ),
"Nominal",
Set Selected,
Set Values( {"a", "a", "a", "b", "b", "b", "c", "c", "c"} )
),
New Column( "Categories",
Character( 1 ),
"Nominal",
Set Values( {"t", "t", "r", "y", "t", "r", "r", "r", "r"} )
),
New Column( "N Categories",
Expression,
"None",
Formula(
If( Row() == 1,
Summarize( x = by( :By column, :Categories ) ),
Empty()
);
N Items( Loc( x[1], :By column ) );
),
Set Display Width( 109 )
),
Set Row States( [1, 0, 0, 0, 0, 0, 0, 0, 0] )
)
I would like to create a custom function doing the same thing as the formula in the N Categories column.
Converting it into a custom function script in the formula editor gives me something like this:
Add Custom Functions(
{New Custom Function(
"custom",
"N Categories",
Function( {Categories,By column},
{Default Local},
If( Row() == 1,
Summarize( x = by( By column, Categories ) ),
Empty()
);
N Items( Loc( x[1], By column ) );
),
<<Description( "" ),
<<Prototype( "" ),
<<Formula Category( "" ),
<<Scripting Index Category( "" ),
<<Result Type( {"Any"} ),
<<Parameter( {"Any"}, "" ),
<<Parameter( {"Any"}, "" )
)}
);
But now the parameters, prior being column references just become parameters containing the values of the rows.
So my question is: Is it possible to create a custom function that treats the parameters as column references?
I could make it work by treating the parameters as column names and transfer strings instead, but it would not be the same!