Here is my version of your code. I separate out the Median and Std Dev data, but then I join the data back together using Update.
Names default to here(1);
dt_summary = New Table( "summary",
Add Rows( 4 ),
Set Header Height( 50 ),
New Column( "Analysis Columns",
Character,
"Nominal",
Set Values( {"Test-1", "Test-1", "Test-2", "Test-2"} )
),
New Column( "Statistics",
Character,
"Nominal",
Set Values( {"Median", "Std Dev", "Median", "Std Dev"} )
),
New Column( "baseline",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 2, 3, 4] )
),
New Column( "risk_lot",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [4, 7, 19, 9] )
)
);
dt_summary << select where( :Statistics == "Std Dev" );
dt_std_subset = dt_summary << subset(
output table( "Std summary" ),
selected rows( 1 ),
selected columns( 0 )
);
dt_summary<<invert row selection;
dt_med_subset = dt_summary << subset(
output table( "Median summary" ),
selected rows( 1 ),
selected columns( 0 )
);
dt_std_subset:baseline << set name("Lot");
dt_std_subset << delete columns({"risk_lot"});
Current Data Table( dt_med_subset );
ncol = N Cols( dt_med_subset );
dt_med_subset << Update(
With( dt_std_subset ),
Match Columns( :Analysis Columns = :Analysis Columns )
);
close( dt_std_subset, nosave );
current data table( dt_med_subset );
for each row(
If( :baseline - 2 * :Lot < :risk_lot < :baseline + 2 * :Lot,
:risk_lot << color cells( "Green", Row()),
:risk_lot << color cells( "Red", Row())
)
);
Jim