Here is an example of setting the number of decimals based upon the column format, when the column switcher changes.
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 20 ),
New Column( "A",
Numeric,
"Continuous",
Format( "Percent", 12, 2 ),
Set Values(
[0.0754692861810327, 0.752831102814525, 0.432255176594481, 0.341968776658177, 0.568129215855151,
0.660923485411331, 0.105864432407543, 0.915830883430317, 0.493037405889481, 0.848509776871651,
0.502906230278313, 0.184636627091095, 0.356515710474923, 0.979479612084105, 0.720729062333703,
0.824798582820222, 0.880037358496338, 0.396357897669077, 0.424773458158597, 0.0499309413135052]
)
),
New Column( "B",
Numeric,
"Continuous",
Format( "Percent", 12, 3 ),
Set Values(
[0.88264535064809, 0.856779424706474, 0.922006396111101, 0.225065165199339, 0.0619992383290082,
0.405686405720189, 0.784316523466259, 0.523665967164561, 0.586588164092973, 0.281117314239964,
0.283934285165742, 0.65784368221648, 0.944990600459277, 0.967821644386276, 0.798449326306581,
0.925142117775976, 0.925621940754354, 0.363795479293913, 0.396030477480963, 0.41240519634448]
)
)
);
ccb = Control Chart Builder( Variables( Y( :A ) ) );
cs = ccb << Column Switcher( :A, {:A, :B} );
Report( ccb )[axisbox( 2 )] << Format( "Percent", 12, 2 );
cs << set Script(
theCol = cs << get current;
theFormat = Char( Column( dt, theCol ) << get format );
theDec = Word( -1, theFormat, ") " );
Eval(
Substitute(
Expr(
Report( ccb )[axisbox( 2 )] << Format( "Percent", 12, _dec_ )
),
Expr( _dec_ ), Num( theDec )
)
);
);
Jim