Hi,
I want to convert this loop into an equivalent column formula
Names Default To Here( 1 );
dt = Current Data Table();
// Assuming Column B is column 2
testColumn = Column( dt, 1 );
llCol = dt << New Column( "LL Limit_7.5", Numeric );
ulCol = dt << New Column( "UL Limit_7.5", Numeric );
// Loop through each row starting from row 20
For( i = 20, i <= N Rows( dt ), i++,
data = testColumn[1 :: i]; // Get values from row 20 to the current row
q1 = Quantile( 0.25, data ); // 1st Quartile
q3 = Quantile( 0.75, data ); // 3rd Quartile
// Factor value is 6
factorValue = 7.5;
// Calculate ll and ul
llx = q1 - (q3 - q1) * (factorValue - 0.675) / 1.35;
ulx = q3 + (q3 - q1) * (factorValue - 0.675) / 1.35;
// Set the calculated values in the new columns
llCol[i] = llx;
ulCol[i] = ulx;
);
I tried but it doesn't seem to be correct. Any advice?
newColExpr = Expr(
llCol << Set Formula(
If( Row() >= 20,
Col Quantile( 0.25, Expr( TestColumn( 1, Row() ) ) ) - (Col Quantile( 0.75, Expr( TestColumn( 1, Row() ) ) )
-Col Quantile( 0.25, Expr( TestColumn( 1, Row() ) ) )) * (Expr( factorValue ) - 0.675) / 1.35,
.
)
);
ulCol << Set Formula(
If( Row() >= 20,
Col Quantile( 0.75, Expr( TestColumn( 1, Row() ) ) ) + (Col Quantile( 0.75, Expr( TestColumn( 1, Row() ) ) )
-Col Quantile( 0.25, Expr( TestColumn( 1, Row() ) ) )) * (Expr( factorValue ) - 0.675) / 1.35,
.
)
);
);
Eval( Eval Expr( newColExpr ) );