topic Re: Column Formulas to slow : how to wait until they are done calculating in Discussions
https://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184806#M40386
<P>Below is a simple modification that should work for you. First, by getting rid of the If() clause it will speed up the processing, and secondly, the </P>
<P> dt << rerun formulas;</P>
<P>will force JMP to complete processing on the formulas before continuing</P>
<PRE><CODE class=" language-jsl">dt = Current Data Table();
dt << New Column( "_Target",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( (:LSL + :USL) / 2 )
);
dt << rerun formulas;</CODE></PRE>Thu, 07 Mar 2019 17:54:45 GMTtxnelson2019-03-07T17:54:45ZColumn Formulas to slow : how to wait until they are done calculating
https://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184796#M40384
<P>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. </P>
<P>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.</P>
<P> </P>
<P>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?</P>
<P> </P>
<P>Does not work </P>
<P>E.g,</P>
<PRE><CODE class=" language-jsl">New Column( "_Target",Numeric,"Continuous",Format( "Best", 12 ),Formula(If( Is Missing( :_LSL ) | Is Missing( :_USL ),
Empty(),
Mean( :_LSL, :_USL )
)</CODE></PRE>
<P> </P>
<P>Workaround</P>
<P>E.g., </P>
<P> </P>
<PRE><CODE class=" language-jsl">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;
,
);</CODE></PRE>
<P> </P>Thu, 07 Mar 2019 17:49:51 GMThttps://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184796#M40384justvince2019-03-07T17:49:51ZRe: Column Formulas to slow : how to wait until they are done calculating
https://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184805#M40385
<P>Try sending your table a 'run formulas' message:</P>
<PRE><CODE class=" language-jsl">dt << runFormulas;</CODE></PRE>Thu, 07 Mar 2019 17:49:24 GMThttps://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184805#M40385ian_jmp2019-03-07T17:49:24ZRe: Column Formulas to slow : how to wait until they are done calculating
https://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184806#M40386
<P>Below is a simple modification that should work for you. First, by getting rid of the If() clause it will speed up the processing, and secondly, the </P>
<P> dt << rerun formulas;</P>
<P>will force JMP to complete processing on the formulas before continuing</P>
<PRE><CODE class=" language-jsl">dt = Current Data Table();
dt << New Column( "_Target",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( (:LSL + :USL) / 2 )
);
dt << rerun formulas;</CODE></PRE>Thu, 07 Mar 2019 17:54:45 GMThttps://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184806#M40386txnelson2019-03-07T17:54:45ZRe: Column Formulas to slow : how to wait until they are done calculating
https://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184890#M40398
Awesome! It works!Thu, 07 Mar 2019 20:47:15 GMThttps://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184890#M40398justvince2019-03-07T20:47:15ZRe: Column Formulas to slow : how to wait until they are done calculating
https://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184891#M40399
NIce, This works too. The rerun formulas is not in the JMP V13 scripting guide, while run formulas is. Both work in this case.Thu, 07 Mar 2019 20:47:17 GMThttps://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184891#M40399justvince2019-03-07T20:47:17ZRe: Column Formulas to slow : how to wait until they are done calculating
https://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184915#M40404
<P>Was not aware of "rerun" either. Looks like it makes the formulas re-evaluate, whether they need it or not. If you use random numbers in your formulas, you can see the difference. I'd recommend <<runFormulas for most cases.</P>Thu, 07 Mar 2019 21:35:41 GMThttps://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/184915#M40404Craige_Hales2019-03-07T21:35:41ZRe: Column Formulas to slow : how to wait until they are done calculating
https://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/185158#M40412
<P>You are correct that this message is not described in the Scripting Guide. It is described in the JSL Syntax Guide. The first book is not a complete description of every function and message in JSL but the second book should be complete. The two books are meant to complement each other and to be used together.</P>
<P> </P>
<P>The message is also covered by the Scripting Index, with a link to the help for it. A search for 'formula' would return a list including the << Run Formulas and << Rerun Formulas messages.</P>Fri, 08 Mar 2019 12:41:02 GMThttps://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/185158#M40412markbailey2019-03-08T12:41:02ZRe: Column Formulas to slow : how to wait until they are done calculating
https://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/186274#M40470
<P>This is a simple "pile on" comment. <LI-USER uid="2687"></LI-USER>'s formula will run fatser than the one you provided. Column formulas run faster than a for loop. Also, the conditional statement is not required, since JMP returns an empty() in any calculation that has an empty value. Thus, (:USL + :LSL)/2 will be empty if any one or both values are empty.</P>
<P> </P>
<P>This is just an FYI.</P>Tue, 12 Mar 2019 10:20:16 GMThttps://community.jmp.com/t5/Discussions/Column-Formulas-to-slow-how-to-wait-until-they-are-done/m-p/186274#M40470gzmorgan02019-03-12T10:20:16Z