In the meantime ...
the only solution seems to be to generate the transform column with table scope , to replace it every time the selection in the local data filter is changed - and to put it back into the Plot every time it gets kicked out.
So it's more like Set each value() than Formula().
On the other hand: it works - just in case you need a plot with a Transform column formula which "automatically" adjusts to changes of the Local Data Filter
To illustrate the idea, I generated a GraphBuilder plot which counts the selected M & F.
Imagine how powerful this approach can be ...
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
colName = "count_"||Char(Random Integer(100000));
Eval(Eval Expr(gb = dt << Graph Builder(
Transform Column(
Expr(colName),
"Table Scope", // essential because otherwise the replace(1) won't work
Formula( Col Number( 1,:sex ) )
),
Variables( X( :sex ), Y( Expr(colName) ) ),
Elements( Bar( X, Y ) ),
Local Data Filter(Add Filter(columns( :sex, :name )))
)));
ldf = (Current Report()["Local Data Filter"] << get scriptable object);
myRowsOld=[];
fch = Function( {x},
myRows = ldf << Get Filtered Rows;
If( not(nrows(myRows)==nrows(myRowsOld))| not(asList(myRows) == asList(myRowsOld)),
myRowsOld = myRows;
Eval(
Substitute(
Expr(
dt << Transform Column(
_colName_,
//"Table Scope", // gb doesn't understand replace(1) -> we have to talk to the table -> no Table Scope needed
Formula(
Col Number( 1, :sex, Contains( _myRows_, Row() ) > 0 )
),
Replace( 1 )
)
),
Expr( _myRows_ ), myRows, Expr(_colName_), colName
)
);
gb << add variable({ Column(colName), Role("Y") }); //replacing the transform column removes it automatically from the graph
dt << Show Transforms();
);
);
current report() << on close(dt << delete column(colname));
rs = ldf << Make Filter Change Handler( fch );
dt << Show Transforms();