Greetings, I have run into situations where I import raw data into a data table (dt1), and then open another data table that has say spec limits (dt2). The spec limits table has an USL and a LSL only. I insert a new calcultated column into dt2 that is the target spec limit (mean(USL,LSL)). I then loop through all rows of my raw data dt1 and if I get a match of the name of the test and spec limits, then set colum properties with the spec limits (e.g., col << Set Property( "Spec Limits", {LSL( myLSLx ),USL( myUSLx ),Target( mytargetx ), );)... Then close spec file dt2, no save.
I think the problem I am having is that the calculated column (dt2:_Target) is not fast enough, and I get all empty values when trying to read them, right after creating the new calculated column("_Target"...). If I keep the dt2 file open, I see the correct values in the calculated column "_Target". I have played with the dt2<< Begin data Update; and that does not work either, but maybe I am putting that in an incorrect location in the script? The only work around I have, is to not use a formula for the new column, but to calculate in a script the target value and place it in the spec file by indexing through all the rows.
The root of my question is, can I wait for all the columns to be completed with calculations before trying to read a specific value in a row/column?
Does not work
E.g,
New Column( "_Target",Numeric,"Continuous",Format( "Best", 12 ),Formula(If( Is Missing( :_LSL ) | Is Missing( :_USL ),
Empty(),
Mean( :_LSL, :_USL )
)
Workaround
E.g.,
dt2 = current data table();
New Column( "_Target", Numeric, "Continuous");
dt2_rows = nrows();
for (i=1, i<=dt2_rows, i++,
if(or(!is missing(dt2:_LSL[i]),!is missing(dt2:_USL[i])),
dt2:_Target[i] = ((dt2:_LSL[i]) + (d2t:_USL[i])) / 2;
,
);
... View more