<?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: How does JMP evaluate a column formula? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822808#M100270</link>
    <description>&lt;P&gt;The next question - and therefore the title of the post:&lt;BR /&gt;why does JMP delete the entries when I close &lt;FONT face="courier new,courier"&gt;dtsum&lt;/FONT&gt;?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6366006503112w1218h540r694" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6366006503112" 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-6366006503112w1218h540r694');  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/6366006503112"&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;Try(close(dt, nosave));
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

Data Table( "Big Class" ) &amp;lt;&amp;lt; Sort(
	By( :age, :height ),
	Replace Table
);

dt &amp;lt;&amp;lt; New Column( " col",
	Formula(
	local({tmp,myAge},
	as constant (
			dt0 = Current Data Table();
			dtsum = dt &amp;lt;&amp;lt; summary( Group( :age, :height ) );
			//dtsum:age &amp;lt;&amp;lt; set name(age2);
			nr = N Rows( dt0 );
		);
		myage = dt:age[row()];
		Eval (Eval Expr(myrows = dtsum &amp;lt;&amp;lt; get rows where( :age == Expr(myAge))));
		Print(myRows);
		tmp = contains(dtsum[myrows,2], :height);
		if(row()==nr,  dt&amp;lt;&amp;lt; runformulas();wait(1);close(dtsum, noSave);Caption("done"));
		tmp
)));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 14 Dec 2024 22:39:09 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2024-12-14T22:39:09Z</dc:date>
    <item>
      <title>How does JMP evaluate a column formula?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822797#M100268</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;just used &lt;FONT face="courier new,courier"&gt;summarize()&lt;/FONT&gt; inside &lt;FONT face="courier new,courier"&gt;as constant:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/Alphabetical-Ranking-of-Nominal-Data/m-p/822725/highlight/true#M100245" target="_blank"&gt;https://community.jmp.com/t5/Discussions/Alphabetical-Ranking-of-Nominal-Data/m-p/822725/highlight/true#M100245&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="courier new,courier"&gt;&lt;CODE class=" language-jsl"&gt;As Constant( Summarize( theLevels = by( :age ) ) );
Contains( theLevels, Char( :age ) );&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very interesting approach!&lt;/P&gt;&lt;P&gt;For &lt;FONT face="courier new,courier"&gt;as constant&lt;/FONT&gt;, the scripting index provides the example&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
New Table( "As Constant Demo Table 1",
	Add Rows( 10 ),
	New Column( "Non-Constant", Formula( Random Uniform() ) ),
	New Column( "Constant", Formula( As Constant( Random Uniform() ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this is easy to understand -&amp;nbsp;&lt;CODE class=" language-jsl"&gt;As Constant( Random Uniform() ) &lt;/CODE&gt;is executed just once and the return value is used for the other rows.&lt;BR /&gt;The thing that puzzled me: The return value of &lt;FONT face="courier new,courier"&gt;Summarize&lt;/FONT&gt; is empty and actually, it's &lt;FONT face="courier new,courier"&gt;&lt;CODE class=" language-jsl"&gt;theLevels &lt;/CODE&gt;&lt;/FONT&gt;which we are interested in.&lt;/P&gt;&lt;P&gt;So, the actual trick is&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;as constant&lt;/FONT&gt;:&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;"is executed just once"&lt;/STRONG&gt;!&amp;nbsp;&lt;BR /&gt;very useful!&lt;BR /&gt;&lt;BR /&gt;Could be used for:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;as constant("JMP just started to evaluate column xyz");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Let's use this trick for another application: to open an auxiliary data table.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt &amp;lt;&amp;lt; New Column( " col",
	Formula(
	as constant (
			dt = Current Data Table();
			dtsum = dt &amp;lt;&amp;lt; summary( Group( :age, :height ) );
			nr = N Rows( dt );
		);

		Eval( (EvalExpr(myrows= dtsum &amp;lt;&amp;lt; get rows where( :age == Expr(dt:age[row()])))));
		Print(:age, myrows);
		dtsum[myrows, 2]
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But it's not as easy as I expected ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hm, it's quite late - I don't have any idea why:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1734214055725.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71222iFD1BF54E30A370DD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1734214055725.png" alt="hogi_0-1734214055725.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2024 23:28:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822797#M100268</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-14T23:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: How does JMP evaluate a column formula?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822808#M100270</link>
      <description>&lt;P&gt;The next question - and therefore the title of the post:&lt;BR /&gt;why does JMP delete the entries when I close &lt;FONT face="courier new,courier"&gt;dtsum&lt;/FONT&gt;?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6366006503112w1218h540r176" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6366006503112" 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-6366006503112w1218h540r176');  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/6366006503112"&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;Try(close(dt, nosave));
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

Data Table( "Big Class" ) &amp;lt;&amp;lt; Sort(
	By( :age, :height ),
	Replace Table
);

dt &amp;lt;&amp;lt; New Column( " col",
	Formula(
	local({tmp,myAge},
	as constant (
			dt0 = Current Data Table();
			dtsum = dt &amp;lt;&amp;lt; summary( Group( :age, :height ) );
			//dtsum:age &amp;lt;&amp;lt; set name(age2);
			nr = N Rows( dt0 );
		);
		myage = dt:age[row()];
		Eval (Eval Expr(myrows = dtsum &amp;lt;&amp;lt; get rows where( :age == Expr(myAge))));
		Print(myRows);
		tmp = contains(dtsum[myrows,2], :height);
		if(row()==nr,  dt&amp;lt;&amp;lt; runformulas();wait(1);close(dtsum, noSave);Caption("done"));
		tmp
)));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Dec 2024 22:39:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822808#M100270</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-14T22:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: How does JMP evaluate a column formula?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822810#M100271</link>
      <description>&lt;P&gt;Issue 1 can be fixed via:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column( " col",
Expression,
	set each value (
	local({tmp,myAge},
	as constant (
			dt0 = Current Data Table();
			dtsum = dt &amp;lt;&amp;lt; summary( Group( :age, :height ) );
			//dtsum:age &amp;lt;&amp;lt; set name(age2);
			nr = N Rows( dt0 );
		);
		myage = dt:age[row()]; // save as variable and use later here  ↘:backhand_index_pointing_down:&lt;/img&gt;
		Eval (Eval Expr(myrows = dtsum &amp;lt;&amp;lt; get rows where( :age == Expr(myAge))));
		dtsum[myrows,2]
)));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Dec 2024 22:57:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822810#M100271</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-14T22:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: How does JMP evaluate a column formula?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822811#M100272</link>
      <description>&lt;P&gt;Wow, and the second one is very surprising, it can be fixed via&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//dense rank - with groupby

dt &amp;lt;&amp;lt; New Column( " col",
	set each value( // &amp;lt;- the first change is here 
	local({tmp,myAge},
	as constant (
			dt = Current Data Table();
			dtsum = dt &amp;lt;&amp;lt; summary( Group( :age, :height ) );
			//dtsum:age &amp;lt;&amp;lt; set name(age2);
			nr = N Rows( dt );
		);
		myage = dt:age[row()];
		Eval (Eval Expr(myrows = dtsum &amp;lt;&amp;lt; get rows where( :age == Expr(myAge))));
		tmp = contains(dtsum[myrows,2],dt:height); // &amp;lt;- the second change is here : use dt:height instead of :height to force JMP to use the right table!
		if(row()==nr, close(dtsum, noSave));
		tmp
)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This also fixes the issue with several "0" entries in the previous approach.&lt;BR /&gt;&lt;BR /&gt;So, under the line, the questions was not:&lt;BR /&gt;&lt;EM&gt;why does JMP delete the values in dt if table dtsum is closed?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;the actual question was:&lt;BR /&gt;why does JMP use &lt;FONT face="courier new, courier"&gt;dtsum:height&amp;nbsp;&lt;/FONT&gt;instead of &lt;FONT face="courier new,courier"&gt;dt:height&lt;/FONT&gt; when calculating entries for the data table&amp;nbsp;&lt;FONT face="courier new,courier"&gt;dt&lt;/FONT&gt;?&lt;BR /&gt;&lt;BR /&gt;open question: why does dt:height just fix the issue for &lt;FONT face="courier new,courier"&gt;set each value()&lt;/FONT&gt; and not for &lt;FONT face="courier new,courier"&gt;formula()&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2024 00:07:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822811#M100272</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-15T00:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: How does JMP evaluate a column formula?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822812#M100273</link>
      <description>&lt;P&gt;Ah,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column( "dense rank_ grouped by",
Character, 
	formula (
	local({tmp,myAge},
	as constant (
			dt = Current Data Table();
			dtsum = dt &amp;lt;&amp;lt; summary( Group( :age, :height ) );
			//dtsum:age &amp;lt;&amp;lt; set name(age2);
			nr = N Rows( dt );
		);
		rw = row();
		myage = dt:age[row()];
		Eval (Eval Expr(myrows = dtsum &amp;lt;&amp;lt; get rows where( dtsum:age == Expr(myAge)))); // &amp;lt;- use dtsum:age !!!
		tmp = contains(dtsum[myrows,2], dt:height[rw]); // &amp;lt;- use dt:height !!!!
		if(row()==nr, close(dtsum, noSave));
		tmp

)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;, I remember, you had a similar issue some while ago - a conflict if two tables have overlapping column names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will add a link when I find it ...&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2024 00:17:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822812#M100273</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-15T00:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: How does JMP evaluate a column formula?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822816#M100275</link>
      <description>&lt;P&gt;Do you mean the issue I mention here &lt;LI-MESSAGE title="Bug when using combination of set each value, tables with same column name(s) and col statistical functions within a loop" uid="665502" url="https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/665502#U665502" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;? &lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2024 06:34:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822816#M100275</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-12-15T06:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: How does JMP evaluate a column formula?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822841#M100279</link>
      <description>&lt;P&gt;Ah, right, this one.&lt;BR /&gt;So, it's not only &lt;FONT face="courier new,courier"&gt;&amp;lt;&amp;lt; set each value()&lt;/FONT&gt; which is affected - &lt;FONT face="courier new,courier"&gt;formula()&lt;/FONT&gt; can be affected as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How fortunate that I could not find your post yesterday.&amp;nbsp;&lt;BR /&gt;I wouldn't have dared &lt;FONT face="courier new,courier"&gt;&amp;lt;&amp;lt; set each value()&amp;nbsp;&lt;/FONT&gt;after reading it ...&lt;BR /&gt;maybe: not as a workaround but as a crosscheck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Interesting: In my case, there is no col statistic involved (like &lt;FONT face="courier new,courier"&gt;col rank()&lt;/FONT&gt;).&lt;/P&gt;&lt;P&gt;Maybe JMP knows that the code was intended to create one ; )&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2024 13:07:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822841#M100279</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-15T13:07:51Z</dc:date>
    </item>
  </channel>
</rss>

