<?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 Bug when using combination of set each value, tables with same column name(s) and col statistical functions within a loop in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/665502#M85377</link>
    <description>&lt;P&gt;This has already been reported to JMP support and they have submitted it as a bug to development (00049239). Seems to happen at least with JMP16.2 and JMP17.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just as a heads up, there is fairly bad bug with JMP when using the mentioned combination (set each value, loop and col statistical functions). What happens is that JMP does use data from wrong table&amp;nbsp;when adding data to different table. One workaround is to provide table preference within &amp;lt;&amp;lt; Set Each Value (&amp;lt;&amp;lt; Set Each Value(Col Rank(Row(), dt:name))).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem to need (based on my fairly quick tests):&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Data tables with same column name(s)&lt;/LI&gt;
&lt;LI&gt;Loop over those&lt;/LI&gt;
&lt;LI&gt;Use &amp;lt;&amp;lt; Set Each Value to set values in column&lt;/LI&gt;
&lt;LI&gt;The formula used should use Col statistical function &lt;STRONG&gt;WITH&lt;/STRONG&gt; byVar (and most likely this has to have same name in both tables)&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below are some test cases&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
// https://www.jmp.com/support/help/en/17.0/#page/jmp/scoping-operators.shtml#

// Initialize data
test_tables = {};
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt &amp;lt;&amp;lt; New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") &amp;lt;&amp;lt; Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
dt = Open("$SAMPLE_DATA/Students1.jmp");
dt &amp;lt;&amp;lt; Sort(By(:name), Replace Table, Order(Ascending)); // sort to create worse scenario
dt &amp;lt;&amp;lt; New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") &amp;lt;&amp;lt; Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
/*
dt = Open("$SAMPLE_DATA/Students2.jmp");
dt &amp;lt;&amp;lt; Sort(By(:name), Replace Table, Order(Ascending)); // sort to create worse scenario
dt &amp;lt;&amp;lt; New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") &amp;lt;&amp;lt; Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
*/

// use idx 1 to skip first table
min_idx = 0;

// without reversing we will run out of index as we are using wrong table
// but if we reverse we will get worse outcome (in my opinion) as we end up with wrong data
reverse_tableorder = 0; 


If(reverse_tableorder,
	test_tables = Reverse(test_tables);
);

For Each({dt, idx}, test_tables,
	// works
	// dt &amp;lt;&amp;lt; New Column("COPY", Character, Nominal, &amp;lt;&amp;lt; Set Each Value(:NAME));
	// dt &amp;lt;&amp;lt; New Column("MULTI", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(:age * :age));

	If(idx &amp;gt; 0, // if the column isn't created to first table seems to work fine?
		// Doesn't work (// old table used due to some col function optimizations when using byVar?)
		Try(
			dt &amp;lt;&amp;lt; New Column("RANK", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(Col Rank(Row(), :NAME)));
		,
			show(exception_msg);
		);

		Try(
			new_col = dt &amp;lt;&amp;lt; New Column("RANK_SEPARATE", Numeric, Continuous);
			new_col &amp;lt;&amp;lt; Set Each Value(Col Rank(:Row(), :name));
		,
			show(exception_msg);
		);

		Try(
			new_col = dt &amp;lt;&amp;lt; New Column("SUM", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(Col Sum(1)));
		,
			show(exception_msg);
		);

		Try(
			new_col = dt &amp;lt;&amp;lt; New Column("SUM_WITH_GROUP", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(Col Sum(1, :name)));
		,
			show(exception_msg);
		);

		Try( // with reverse_tableorder = 1, :age is taken from correct table BUT the group sizes from wrong? 
		// KATIE -&amp;gt; 72 (6*12) and not 11+12+12+13+14+15 -&amp;gt; 77
			new_col = dt &amp;lt;&amp;lt; New Column("SUM_OF_COL", Numeric, Continuous);
			new_col &amp;lt;&amp;lt; Set Each Value(Col Sum(:age, :name));
		,
			show(exception_msg);
		);

		// workaround
		dt &amp;lt;&amp;lt; New Column("RANK_WITH_REF", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(
			Col Rank(Row(), dt:NAME)
		));
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Aug 2023 05:54:05 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-08-04T05:54:05Z</dc:date>
    <item>
      <title>Bug when using combination of set each value, tables with same column name(s) and col statistical functions within a loop</title>
      <link>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/665502#M85377</link>
      <description>&lt;P&gt;This has already been reported to JMP support and they have submitted it as a bug to development (00049239). Seems to happen at least with JMP16.2 and JMP17.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just as a heads up, there is fairly bad bug with JMP when using the mentioned combination (set each value, loop and col statistical functions). What happens is that JMP does use data from wrong table&amp;nbsp;when adding data to different table. One workaround is to provide table preference within &amp;lt;&amp;lt; Set Each Value (&amp;lt;&amp;lt; Set Each Value(Col Rank(Row(), dt:name))).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem to need (based on my fairly quick tests):&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Data tables with same column name(s)&lt;/LI&gt;
&lt;LI&gt;Loop over those&lt;/LI&gt;
&lt;LI&gt;Use &amp;lt;&amp;lt; Set Each Value to set values in column&lt;/LI&gt;
&lt;LI&gt;The formula used should use Col statistical function &lt;STRONG&gt;WITH&lt;/STRONG&gt; byVar (and most likely this has to have same name in both tables)&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below are some test cases&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
// https://www.jmp.com/support/help/en/17.0/#page/jmp/scoping-operators.shtml#

// Initialize data
test_tables = {};
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt &amp;lt;&amp;lt; New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") &amp;lt;&amp;lt; Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
dt = Open("$SAMPLE_DATA/Students1.jmp");
dt &amp;lt;&amp;lt; Sort(By(:name), Replace Table, Order(Ascending)); // sort to create worse scenario
dt &amp;lt;&amp;lt; New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") &amp;lt;&amp;lt; Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
/*
dt = Open("$SAMPLE_DATA/Students2.jmp");
dt &amp;lt;&amp;lt; Sort(By(:name), Replace Table, Order(Ascending)); // sort to create worse scenario
dt &amp;lt;&amp;lt; New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") &amp;lt;&amp;lt; Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
*/

// use idx 1 to skip first table
min_idx = 0;

// without reversing we will run out of index as we are using wrong table
// but if we reverse we will get worse outcome (in my opinion) as we end up with wrong data
reverse_tableorder = 0; 


If(reverse_tableorder,
	test_tables = Reverse(test_tables);
);

For Each({dt, idx}, test_tables,
	// works
	// dt &amp;lt;&amp;lt; New Column("COPY", Character, Nominal, &amp;lt;&amp;lt; Set Each Value(:NAME));
	// dt &amp;lt;&amp;lt; New Column("MULTI", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(:age * :age));

	If(idx &amp;gt; 0, // if the column isn't created to first table seems to work fine?
		// Doesn't work (// old table used due to some col function optimizations when using byVar?)
		Try(
			dt &amp;lt;&amp;lt; New Column("RANK", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(Col Rank(Row(), :NAME)));
		,
			show(exception_msg);
		);

		Try(
			new_col = dt &amp;lt;&amp;lt; New Column("RANK_SEPARATE", Numeric, Continuous);
			new_col &amp;lt;&amp;lt; Set Each Value(Col Rank(:Row(), :name));
		,
			show(exception_msg);
		);

		Try(
			new_col = dt &amp;lt;&amp;lt; New Column("SUM", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(Col Sum(1)));
		,
			show(exception_msg);
		);

		Try(
			new_col = dt &amp;lt;&amp;lt; New Column("SUM_WITH_GROUP", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(Col Sum(1, :name)));
		,
			show(exception_msg);
		);

		Try( // with reverse_tableorder = 1, :age is taken from correct table BUT the group sizes from wrong? 
		// KATIE -&amp;gt; 72 (6*12) and not 11+12+12+13+14+15 -&amp;gt; 77
			new_col = dt &amp;lt;&amp;lt; New Column("SUM_OF_COL", Numeric, Continuous);
			new_col &amp;lt;&amp;lt; Set Each Value(Col Sum(:age, :name));
		,
			show(exception_msg);
		);

		// workaround
		dt &amp;lt;&amp;lt; New Column("RANK_WITH_REF", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(
			Col Rank(Row(), dt:NAME)
		));
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Aug 2023 05:54:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/665502#M85377</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-08-04T05:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Bug when using combination of set each value, tables with same column name(s) and col statistical functions within a loop</title>
      <link>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/666950#M85497</link>
      <description>&lt;P&gt;Got some good information not so good information from JMP support.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good:&lt;/P&gt;
&lt;P&gt;This is a bug with Col Rank function (not sure if other Col functions were tested) and will be fixed at some point (fix won't be there for JMP17.2).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Definitely not so good:&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;lt; Set Each Value shouldn't be used to set values to columns unless it is a constant or 'global function' (today()) and first argument in Col statistical functions should always be column reference. The current behaviours aren't considered bugs but rather unintended behaviours so they are a subject to change any point without any information. I will create wish list item so they would make these into supported behaviours instead of unintended behaviours.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;LI-MESSAGE title="Make using formula expressions in Set Each Value and using expressions as first argument in Col statistical formulas supported behaviour" uid="666966" url="https://community.jmp.com/t5/JMP-Wish-List/Make-using-formula-expressions-in-Set-Each-Value-and-using/m-p/666966#U666966" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 07:17:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/666950#M85497</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-08-09T07:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Bug when using combination of set each value, tables with same column name(s) and col statistical functions within a loop</title>
      <link>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/667052#M85506</link>
      <description>&lt;P&gt;Col statistics with the strict requirement to use a column as the fist&amp;nbsp; argument - forbidden to use an expression ?&lt;BR /&gt;This will be a huge step backwards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many of the beautiful tricks of&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3552"&gt;@brady_brady&lt;/a&gt;&amp;nbsp;wont work anymore :(&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 15:54:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/667052#M85506</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-08-09T15:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Bug when using combination of set each value, tables with same column name(s) and col statistical functions within a loop</title>
      <link>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/800532#M97618</link>
      <description>&lt;P&gt;with JMP18: great, seems to be fixed:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1726776134928.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68477i0FCEC29875D2F9E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_1-1726776134928.png" alt="hogi_1-1726776134928.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but Col Sums seem to still have an issue ...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_2-1726776156148.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68478i5430BD2F8E35EE60/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_2-1726776156148.png" alt="hogi_2-1726776156148.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this issue can be fixed by explicitly referring to dataTable:column, analogous to Jarmo's example in the fist post:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;new_col = dt &amp;lt;&amp;lt; New Column("SUM_WITH_GROUP", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(Col Sum(1, dt:name))); // dt:name instead of name

new_col &amp;lt;&amp;lt; Set Each Value(Col Sum(dt:age, dt:name));&amp;nbsp;//&amp;nbsp;dt:age(name)&amp;nbsp;instead&amp;nbsp;of&amp;nbsp;:age(name)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Dec 2024 18:00:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/800532#M97618</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-15T18:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Bug when using combination of set each value, tables with same column name(s) and col statistical functions within a loop</title>
      <link>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/823041#M100281</link>
      <description>&lt;P&gt;a related issue with formula columns:&lt;/P&gt;&lt;P&gt;&lt;LI-MESSAGE title="How does JMP evaluate a column formula?" uid="822797" url="https://community.jmp.com/t5/Discussions/How-does-JMP-evaluate-a-column-formula/m-p/822797#U822797" 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 18:01:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/823041#M100281</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-15T18:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Bug when using combination of set each value, tables with same column name(s) and col statistical functions within a loop</title>
      <link>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/901643#M106083</link>
      <description>&lt;P&gt;&lt;SPAN&gt;fixed in JMP19:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa" href="https://community.jmp.com/t5/Discussions/Tiny-Traps-in-Jmp-and-JSL/m-p/702685#U702685" target="_blank"&gt;Tiny Traps in Jmp and JSL&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1758184358731.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/82798iC64AC687B49E8701/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1758184358731.png" alt="hogi_0-1758184358731.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Sep 2025 10:49:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bug-when-using-combination-of-set-each-value-tables-with-same/m-p/901643#M106083</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-09-18T10:49:20Z</dc:date>
    </item>
  </channel>
</rss>

