<?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 Expr and Name Expr in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/696129#M88133</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am analyzing larger amounts of data, 350k rows.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For each row, the code runs a loop to calculate the unique delta between table 1 and table 2 and then add that delta to the column of the main data table. Something is not correct in the below code. Any suggestion?&lt;/SPAN&gt;&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 );
dt1 = Data Table( "dt_ref" );
dt2 = Data Table( "Data table" );

digt = 5;
itsel1 = {"Currents A", "Currents A2", "Currents A3", "Currents A4", "Currents A5"}; //List of columns to align.&lt;BR /&gt;
//// Loop to calculate the delta between the dt1 and dt2 and the add the delta to the column of dt2 from the itsel1 list
dt2 &amp;lt;&amp;lt; Add Row( 1, At Start );
dt2 &amp;lt;&amp;lt; Begin Data Update;

For Each( {element, idx}, itsel1,
	Eval(
		Eval Expr(
			Column( dt2, element ) &amp;lt;&amp;lt; Set Each Value(
				Expr(
					Name Expr( Column( dt2, element ) )
				),
				Expr(
					Num(
						Substr( Char( Column( dt1, "Median" )[dt1 &amp;lt;&amp;lt; get rows where( :Tests == element )] - Column( dt2, element ) ), 1, digt + 1 )
					) + Column( dt2, element )
				)
			)
		)
	)
);


dt2 &amp;lt;&amp;lt; Delete Row( 1 );
dt2 &amp;lt;&amp;lt; End Data Update;
	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Jackie&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2023 14:35:54 GMT</pubDate>
    <dc:creator>Jackie_</dc:creator>
    <dc:date>2023-11-09T14:35:54Z</dc:date>
    <item>
      <title>Expr and Name Expr</title>
      <link>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/696129#M88133</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am analyzing larger amounts of data, 350k rows.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For each row, the code runs a loop to calculate the unique delta between table 1 and table 2 and then add that delta to the column of the main data table. Something is not correct in the below code. Any suggestion?&lt;/SPAN&gt;&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 );
dt1 = Data Table( "dt_ref" );
dt2 = Data Table( "Data table" );

digt = 5;
itsel1 = {"Currents A", "Currents A2", "Currents A3", "Currents A4", "Currents A5"}; //List of columns to align.&lt;BR /&gt;
//// Loop to calculate the delta between the dt1 and dt2 and the add the delta to the column of dt2 from the itsel1 list
dt2 &amp;lt;&amp;lt; Add Row( 1, At Start );
dt2 &amp;lt;&amp;lt; Begin Data Update;

For Each( {element, idx}, itsel1,
	Eval(
		Eval Expr(
			Column( dt2, element ) &amp;lt;&amp;lt; Set Each Value(
				Expr(
					Name Expr( Column( dt2, element ) )
				),
				Expr(
					Num(
						Substr( Char( Column( dt1, "Median" )[dt1 &amp;lt;&amp;lt; get rows where( :Tests == element )] - Column( dt2, element ) ), 1, digt + 1 )
					) + Column( dt2, element )
				)
			)
		)
	)
);


dt2 &amp;lt;&amp;lt; Delete Row( 1 );
dt2 &amp;lt;&amp;lt; End Data Update;
	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Jackie&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:35:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/696129#M88133</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-11-09T14:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Expr and Name Expr</title>
      <link>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/696166#M88135</link>
      <description>&lt;P&gt;I'm not sure what type of calculation you are performing here&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Num(Substr(Char(Column(dt1, "Median")[dt1 &amp;lt;&amp;lt; get rows where(:Tests == element)] - Column(dt2, element)), 1, digt + 1)) + Column(dt2, element)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but something like this might help you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt1 = Open("$DOWNLOADS/dt_ref.jmp");
dt2 = Open("$DOWNLOADS/Data table.jmp");

digt = 5;
itsel1 = {"Currents A", "Currents A2", "Currents A3", "Currents A4", "Currents A5"}; //List of columns to align.
dt2_colnames = dt2 &amp;lt;&amp;lt; Get Column Names("String");
//// Loop to calculate the delta between the dt1 and dt2 and the add the delta to the column of dt2 from the itsel1 list

For Each({colname}, itsel1,
	dt2_col_idx = Contains(dt2_colnames, colname);
	If(dt2_col_idx == 0,
		Print("Skipped column: " || colname);
		continue(); // skip this column
	);
	
	dt1_row_idx = Loc(dt1[0, "Tests"], colname);
	If(N Items(dt1_row_idx) == 0,
		Print("Skipped row: " || colname);
		continue();
	,
		dt1_row_idx = dt1_row_idx[1]; 
	);
	
	dt2[0, dt2_col_idx] = dt2[0, dt2_col_idx] - dt1[dt1_row_idx, "Median"];
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2023 15:47:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/696166#M88135</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-11-09T15:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Expr and Name Expr</title>
      <link>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/696190#M88138</link>
      <description>&lt;P&gt;So I am trying to align the data in dt2 with the median values of Test in dt1&lt;BR /&gt;&lt;BR /&gt;So The median value of Current A1 is 5.408 so subtract each rows of Current A1 in dt2 and add that back to the row values of Current A1 in dt2&lt;BR /&gt;5.408 - 2.4963333333 =&amp;nbsp; 2.912&lt;/P&gt;&lt;P&gt;2.912 + 2.496333333 = 5.40. I avoiding traditional for loops bcos I have a huge dataset with 1M rows and Expr would be faster&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jackie__0-1699545397227.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/58502i31805B7B22D9F955/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jackie__0-1699545397227.png" alt="Jackie__0-1699545397227.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 16:00:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/696190#M88138</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-11-09T16:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Expr and Name Expr</title>
      <link>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/697195#M88265</link>
      <description>&lt;P&gt;Wouldn't you just end up with the median value if you don't round your values?&lt;/P&gt;
&lt;P&gt;x = median,&lt;/P&gt;
&lt;P&gt;y = row value,&lt;/P&gt;
&lt;P&gt;z = result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;x - y = z&lt;/P&gt;
&lt;P&gt;z + y = x?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Nov 2023 14:34:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/697195#M88265</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-11-12T14:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Expr and Name Expr</title>
      <link>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/697537#M88305</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;That's correct but I want to round off&amp;nbsp; "z" to 2 decimals and then add it back to y. The reason for doing this is "offsetting the tester data with the master data"&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 18:18:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Expr-and-Name-Expr/m-p/697537#M88305</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-11-13T18:18:12Z</dc:date>
    </item>
  </channel>
</rss>

