<?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 to match values for two columns while order could be different in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-match-values-for-two-columns-while-order-could-be/m-p/411522#M66106</link>
    <description>&lt;P&gt;Here is one approach.&amp;nbsp; I determines the difference between the two points, and then applies the New/Repeat logic to the difference.&amp;nbsp; I believe you have an error in your data table, that shows up in the new calculation&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 = Current Data Table();

xFudge = Abs( Min( Col Min( :"x-before"n ), Col Min( :"x-after"n ) ) );
yFudge = Abs( Min( Col Min( :"y-before"n ), Col Min( :"y-after"n ) ) );
//dt &amp;lt;&amp;lt; New Column( "diff" );
dt &amp;lt;&amp;lt; New Column( "Repeat_New", character );

For Each Row(
	diff = Sqrt(
		((xFudge + :"x-before"n) - (xFudge + :"x-after"n)) ^ 2 + ((yFudge + :"y-before"n) - (yFudge +
		:"y-after"n)) ^ 2
	);
	If( diff &amp;lt; 100 | isMissing(diff)
	,
		:Repeat_New = "Repeat";
	,
		:Repeat_New = "New"
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Aug 2021 12:07:44 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2021-08-20T12:07:44Z</dc:date>
    <item>
      <title>How to match values for two columns while order could be different</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-match-values-for-two-columns-while-order-could-be/m-p/411502#M66105</link>
      <description>&lt;P&gt;Say I measured defect for a wafer twice, and have X, Y axis data for each defect.&lt;/P&gt;&lt;P&gt;Some defects are repeat defect, they have very similar axis data (although not exact the same), so I would put "repeat" tag for them, while some defect do not have match, so I would put "new" tag for them.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;How do I write a formula to automatically do this? (ie: formula to auto make column "judge base on after")&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(Note that for same defect, values are not exact the same, just very close. And same defect could be in different row for before &amp;amp; after)&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;X-Before&lt;/TD&gt;&lt;TD&gt;Y-Before&lt;/TD&gt;&lt;TD&gt;X-After&lt;/TD&gt;&lt;TD&gt;Y-After&lt;/TD&gt;&lt;TD&gt;judge base on after&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;-446659&lt;/TD&gt;&lt;TD&gt;888856&lt;/TD&gt;&lt;TD&gt;-446649&lt;/TD&gt;&lt;TD&gt;888852&lt;/TD&gt;&lt;TD&gt;Repeat&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;-445908&lt;/TD&gt;&lt;TD&gt;630775&lt;/TD&gt;&lt;TD&gt;-445899&lt;/TD&gt;&lt;TD&gt;630772&lt;/TD&gt;&lt;TD&gt;Repeat&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;-447462&lt;/TD&gt;&lt;TD&gt;301534&lt;/TD&gt;&lt;TD&gt;-446122&lt;/TD&gt;&lt;TD&gt;588199&lt;/TD&gt;&lt;TD&gt;new&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;-140914&lt;/TD&gt;&lt;TD&gt;508425&lt;/TD&gt;&lt;TD&gt;-447456&lt;/TD&gt;&lt;TD&gt;301532&lt;/TD&gt;&lt;TD&gt;Repeat&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;-140907&lt;/TD&gt;&lt;TD&gt;508433&lt;/TD&gt;&lt;TD&gt;Repeat&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:35:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-match-values-for-two-columns-while-order-could-be/m-p/411502#M66105</guid>
      <dc:creator>Hans_Hsu</dc:creator>
      <dc:date>2023-06-10T23:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to match values for two columns while order could be different</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-match-values-for-two-columns-while-order-could-be/m-p/411522#M66106</link>
      <description>&lt;P&gt;Here is one approach.&amp;nbsp; I determines the difference between the two points, and then applies the New/Repeat logic to the difference.&amp;nbsp; I believe you have an error in your data table, that shows up in the new calculation&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 = Current Data Table();

xFudge = Abs( Min( Col Min( :"x-before"n ), Col Min( :"x-after"n ) ) );
yFudge = Abs( Min( Col Min( :"y-before"n ), Col Min( :"y-after"n ) ) );
//dt &amp;lt;&amp;lt; New Column( "diff" );
dt &amp;lt;&amp;lt; New Column( "Repeat_New", character );

For Each Row(
	diff = Sqrt(
		((xFudge + :"x-before"n) - (xFudge + :"x-after"n)) ^ 2 + ((yFudge + :"y-before"n) - (yFudge +
		:"y-after"n)) ^ 2
	);
	If( diff &amp;lt; 100 | isMissing(diff)
	,
		:Repeat_New = "Repeat";
	,
		:Repeat_New = "New"
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Aug 2021 12:07:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-match-values-for-two-columns-while-order-could-be/m-p/411522#M66106</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-08-20T12:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to match values for two columns while order could be different</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-match-values-for-two-columns-while-order-could-be/m-p/411571#M66114</link>
      <description>&lt;P&gt;Hi txnelson,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply, I tried your method. However, there is a problem.&lt;/P&gt;&lt;P&gt;It seems you only compare data at same the row.&lt;/P&gt;&lt;P&gt;The real situation is:&lt;/P&gt;&lt;P&gt;For before, there could be 500 defects, ie 500 rows. For after, there could be 1000 rows.&lt;/P&gt;&lt;P&gt;Same defect may locate at row 50# in before column, and locates in row 121 in after column, you won't know.&lt;/P&gt;&lt;P&gt;So it is necessary to compare all 1000 rows of after, with all 500 rows of before to match every repeat defect.&lt;/P&gt;&lt;P&gt;The match result may be: 490 among 500 could find a match, 10 were missing, and the other 500 are new adder&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 14:48:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-match-values-for-two-columns-while-order-could-be/m-p/411571#M66114</guid>
      <dc:creator>Hans_Hsu</dc:creator>
      <dc:date>2021-08-20T14:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to match values for two columns while order could be different</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-match-values-for-two-columns-while-order-could-be/m-p/411721#M66122</link>
      <description>&lt;P&gt;Thank you for the clarification.&amp;nbsp; The key to this script is the understanding of the function&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;dt &amp;lt;&amp;lt; get rows where()&lt;/P&gt;
&lt;P&gt;And then looping through all of the rows that have valid Before X and Y values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

xFudge = Abs( Min( Col Min( :"x-before"n ), Col Min( :"x-after"n ) ) );
yFudge = Abs( Min( Col Min( :"y-before"n ), Col Min( :"y-after"n ) ) );
dt &amp;lt;&amp;lt; New Column( "Repeat_New", character, set each value( "New" ) );

For( i = 1, i &amp;lt;= N Rows( dt ), i++,
	If( Is Missing( :"x-before"n[i] + :"y-before"n[i] ) == 0,
		Try(
			:Repeat_New[dt &amp;lt;&amp;lt; get rows where(
				Sqrt(
					((xFudge + :"x-before"n[i]) - (xFudge + :"x-after"n)) ^ 2 + ((yFudge
					+:"y-before"n[i]) - (yFudge + :"y-after"n)) ^ 2
				) &amp;lt; 100 &amp;amp; Row() &amp;gt;= i
			)] = "Repeat"
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Given your estimate of how many rows your data table may have, you can expect the script to take a significant amount of time to process.&lt;/P&gt;
&lt;P&gt;My use of &amp;lt;= 100 units as the distance considered to be the same defect, is just my guess.&amp;nbsp; I have no real way to set that value, given that I do not know the resolution of the defect measurement tool and your stepper resolution capability.&amp;nbsp; But, you should be able to estimate the tool variability and from that setting the distance units.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 06:29:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-match-values-for-two-columns-while-order-could-be/m-p/411721#M66122</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-08-21T06:29:06Z</dc:date>
    </item>
  </channel>
</rss>

