<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: What makes the formula evaluate over and over? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/718059#M89990</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1893"&gt;@Audrey_Shull&lt;/a&gt;&amp;nbsp;, do I have to submit a wish to the wish list&amp;nbsp; - or do you think that the bug gets fixed automatically?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 21 Jan 2024 19:21:56 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2024-01-21T19:21:56Z</dc:date>
    <item>
      <title>What makes the formula evaluate over and over?</title>
      <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695321#M88038</link>
      <description>&lt;P&gt;I noticed an unexpected behavior in Jmp:&lt;/P&gt;&lt;P&gt;After creating a&amp;nbsp;Formula column with a Custom Formula, another Formula Column gets evaluated &lt;STRONG&gt;every time&lt;/STRONG&gt; I select a cell in the data table.&lt;/P&gt;&lt;P&gt;Why is the formula evaluated so many times?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;removing the &lt;FONT face="courier new,courier"&gt;myX =1; myX&lt;/FONT&gt;&amp;nbsp;fro the first formula stops the behavior&lt;/LI&gt;&lt;LI&gt;removing the custom formula from the second formula stops the behavior&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jmp 17.2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

row_count = 10;
dt = New Table( "myTable", Add Rows( row_count ), New Column( "X", set each value( Row() ) ) );


dt &amp;lt;&amp;lt; New Column( "Formula As Constant",
	Formula(
		if(row()==1,write("\!N"));
		Write("+1 ");
		myX = 1;
		myX
	)
);

new namespace("test");

Add Custom Functions( New Custom Function( "test", "myFunc", Function( {}, 1 ) ) );

dt &amp;lt;&amp;lt; New Column( "Formula via Custom Formula", Formula( test:myFunc() ) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 19:11:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695321#M88038</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-11-07T19:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: What makes the formula evaluate over and over?</title>
      <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695333#M88039</link>
      <description>&lt;P&gt;Maybe JMP is for some reason forced to perform re-evaluation if formula columns with custom functions are used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using JMP's example custom formula and Craige's example from &lt;A href="https://community.jmp.com/t5/Discussions/Why-does-selecting-deselecting-rows-trigger-column-formulas-to/m-p/188823/highlight/true#M40750" target="_self"&gt;https://community.jmp.com/t5/Discussions/Why-does-selecting-deselecting-rows-trigger-column-formulas-to/m-p/188823/highlight/true#M40750&lt;/A&gt; . Run the script, select one row, check lo, run rest of the script after stop, click row again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	add rows(3), 
	// EVERYTHINGCOL depends on everything. it evaluates last.
	New Column("EVERYTHINGCOL", Formula(
			Write("\!nEVERYTHINGCOL,row" || Char(Row()));
			:ROWSTATECOL + :INDEPCOL + :DEPONINDEP;
		)
	), 
	// DEPONINDEP depends on INDEPCOL, but not ROWSTATECOL.
	New Column("DEPONINDEP",
		Formula(
			Write("\!nDEPONINDEP,row" || Char(Row()));
			:INDEPCOL + 1;
		)
	), 
	// INDEPCOL is independent. It evaluates early, maybe first.
	New Column("INDEPCOL",
		Formula(
			Write("\!nINDEPCOL,row" || Char(Row()));
			17;
		)
	), 
	// ROWSTATECOL is directly dependent on row state information. It evaluates early, maybe first. 
	New Column("ROWSTATECOL",
		Formula(
			Write("\!nROWSTATECOL,row" || Char(Row()));
			Selected(Row State());
		)
	)
);

dt &amp;lt;&amp;lt; Run Formulas;
Write("\!N -------------------- INITIAL PRINTS----------------\!N");
// Clear Log();
dt &amp;lt;&amp;lt; select rows(1);
dt &amp;lt;&amp;lt; Run Formulas;
Write("\!N -------------------- SEL ROW PRINTS 1----------------\!N");

funcDef = Function({x, y = 10}, x + y);
newAdd = New Custom Function("myNamespace", "Add Ten", funcDef);
newAdd &amp;lt;&amp;lt; Formula Category("NumberStuff");
Add Custom Functions(newAdd);

new_col = dt &amp;lt;&amp;lt; New Column("AddTen", Formula(
	Write("\!nAddTen,row" || Char(Row()));
	myNamespace:Add Ten(Row(), 1))
);
dt &amp;lt;&amp;lt; select rows(2);
dt &amp;lt;&amp;lt; Run Formulas;

Write("\!N -------------------- SEL ROW PRINTS 2----------------\!N");
// new_col &amp;lt;&amp;lt; Suppress Eval(1);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also see this behavior if you just rerun &amp;lt;&amp;lt; Run Formulas. If you don't have the custom formula there, nothing is printed (except for Scriptable[]) and if you add the formula using custom function, all the formulas will be rerun on each &amp;lt;&amp;lt; Run Formulas (basically behaves like &amp;lt;&amp;lt; rerun formulas, all formulas "must be" re-evaluated).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 19:48:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695333#M88039</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-11-07T19:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: What makes the formula evaluate over and over?</title>
      <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695363#M88044</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Maybe JMP is for some reason forced to perform re-evaluation if formula columns with custom functions are used.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Does that mean that customs functions in formula columns are even more "nasty" than formula columns with rowstates in the formula ... because they trigger the evaluation of All Formula columns, not just the dependent ones?&lt;/P&gt;&lt;P&gt;Ouch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;-&amp;gt; If your tables are &amp;gt;&amp;nbsp; 100k rows and you have some formula columns - think twice before using Custom Functions?&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris' problem also immediately came to my mind when I observed this behavior today. I had no time yet to ask:&lt;BR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/12851"&gt;@Chris_Rodrigues&lt;/a&gt;&amp;nbsp;, did you use some custom functions in you table [edit - or namespaces ... see below] ?&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;&amp;nbsp;, fyi.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 20:59:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695363#M88044</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-11-08T20:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: What makes the formula evaluate over and over?</title>
      <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695636#M88072</link>
      <description>&lt;P&gt;When manually selecting cells ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Interesting #1:&lt;/P&gt;&lt;P&gt;(concerning columns like c3 without variables) just the last selected row and the newly selected row gets updated (track the timestamps). Maybe with the idea: &lt;EM&gt;These are the 2 rows with a potential manual change&lt;/EM&gt;?&lt;/P&gt;&lt;P&gt;Hm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Interesting #2:&lt;/P&gt;&lt;P&gt;For formula column with a variable, like c1, the whole column is evaluated again.&lt;/P&gt;&lt;P&gt;Maybe with the idea: The variable could have changed, so let's be sure and update all values.&lt;/P&gt;&lt;P&gt;But on the other hand, changing the variable via JSL (i=-1000) doesn't trigger an update (?)&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6340730244112w1004h540r390" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6340730244112" data-account="6058004218001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6058004218001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6340730244112w1004h540r390');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://community.jmp.com/t5/video/gallerypage/video-id/6340730244112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = New Table( "myTable", Add Rows( 5 ) );

i=0;

// watch(i,j);

dt &amp;lt;&amp;lt; New Column( "c1",	Formula(if(row()==1,i++;write("\!n"),write("c1 "));i));
write("\!n");
dt &amp;lt;&amp;lt; New Column( "c3",	Formula( write("c3 " );today() ));
write("\!n");

Add Custom Functions( New Custom Function( "myNS", "myFunc", Function( {}, 1 ) ) );
dt &amp;lt;&amp;lt; New Column( "trigger", Formula( myNS:myFunc() ) );

i=-1000;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 11:49:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695636#M88072</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-11-08T11:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: What makes the formula evaluate over and over?</title>
      <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695662#M88075</link>
      <description>&lt;P&gt;I don't think the formula evaluator plays well with namespaces. Looks like a bug. &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1893"&gt;@Audrey_Shull&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run this up to the &lt;EM&gt;ok so far comment&lt;/EM&gt;, click some rows, watch the log...it is quiet. Then run the two lines from the work-around section, and the log is still quiet when clicking rows. But start over and use the other two lines, the log is noisy.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;row_count = 10;
dt = New Table( "myTable", Add Rows( row_count ), New Column( "X", set each value( Row() ) ) );

dt &amp;lt;&amp;lt; New Column( "aaa",
	Formula(
		if(row()==1,write("\!N"));
		Write("a");
		myX = x+1;
		myX
	)
);

new namespace("test");
test:xyzzy = 42;

Add Custom Functions( New Custom Function( "test", "myFuncB", 
	Function( {}, Write("b");x=randominteger(1,9);1 ) ) );

wrapperB=function({},test:myFuncB());

dt &amp;lt;&amp;lt; New Column( "bbb", Formula( wrapperB() ) );
//
// ok so far. Either of the following trigger the issue.
// apparently using a namespace in a formula has something to do with it.
//
dt &amp;lt;&amp;lt; New Column( "bbbNameSpace", Formula( test:myFuncB() ) );
dt&amp;lt;&amp;lt;newcolumn("xyzzyNameSpace",formula(test:xyzzy));
//
// you can use a workaround like this to prevent the formula
// evaluator from seeing the namespace
//
dt &amp;lt;&amp;lt; New Column( "bbbNameSpace2", Formula( ttt=namespace("test")["myFuncB"];ttt() ) );
dt&amp;lt;&amp;lt;newcolumn("xyzzyNameSpace",formula(namespace("test")["xyzzy"]));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 13:20:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695662#M88075</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-11-08T13:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: What makes the formula evaluate over and over?</title>
      <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695669#M88079</link>
      <description>&lt;P&gt;conclusive story :)&lt;/img&gt;&lt;BR /&gt;&lt;BR /&gt;thank you for the workaround ...&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 21:22:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695669#M88079</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-11-08T21:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: What makes the formula evaluate over and over?</title>
      <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695884#M88103</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;&amp;nbsp;for the great example - i submitted it to Development.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 20:13:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/695884#M88103</guid>
      <dc:creator>Audrey_Shull</dc:creator>
      <dc:date>2023-11-08T20:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: What makes the formula evaluate over and over?</title>
      <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/718059#M89990</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1893"&gt;@Audrey_Shull&lt;/a&gt;&amp;nbsp;, do I have to submit a wish to the wish list&amp;nbsp; - or do you think that the bug gets fixed automatically?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jan 2024 19:21:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/718059#M89990</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-01-21T19:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: What makes the formula evaluate over and over?</title>
      <link>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/718313#M90077</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26800"&gt;@hogi&lt;/a&gt;&amp;nbsp;- Wish List items are generally used for future functionality requests. Bugs should be reported through Technical Support, or, when they are reported here, sometimes staff monitoring the forums will report them to Development on your behalf, as i did in this example. A duplicate Wish List item should not be necessary.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 16:51:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-makes-the-formula-evaluate-over-and-over/m-p/718313#M90077</guid>
      <dc:creator>Audrey_Shull</dc:creator>
      <dc:date>2024-01-24T16:51:55Z</dc:date>
    </item>
  </channel>
</rss>

