<?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: join tables based on matched columns and closest match column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829494#M101161</link>
    <description>&lt;P&gt;thanks for the quick replay.&lt;/P&gt;&lt;P&gt;this works great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried to add a statement-&amp;nbsp; if :Distance &amp;lt;30 don't show the results, only the reference.&lt;/P&gt;&lt;P&gt;but ended without the results where distance &amp;gt;30.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there an option to add this condition ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jan 2025 15:01:21 GMT</pubDate>
    <dc:creator>Ohad_s</dc:creator>
    <dc:date>2025-01-28T15:01:21Z</dc:date>
    <item>
      <title>join tables based on matched columns and closest match column</title>
      <link>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829453#M101151</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to join two tables.&lt;/P&gt;&lt;P&gt;I have full match on two column and closest match on two other columns.&lt;/P&gt;&lt;P&gt;Each table with different number of row.&lt;/P&gt;&lt;P&gt;reference sorted= 108 rows&lt;/P&gt;&lt;P&gt;scan sorted= 193 rows&lt;/P&gt;&lt;P&gt;I want the final table to have all the row from the reference table, 108 rows, + the matching data from the second table.&lt;/P&gt;&lt;P&gt;exact match columns:&lt;/P&gt;&lt;P&gt;1. Row Reference= Row Scan&lt;/P&gt;&lt;P&gt;2. Col Reference= Col Scan&lt;/P&gt;&lt;P&gt;closest match columns:&lt;/P&gt;&lt;P&gt;1. X Coordinates Reference= X Coordinates Scan&lt;/P&gt;&lt;P&gt;2. Y&amp;nbsp;Coordinates Reference= Y Coordinates Scan&lt;/P&gt;&lt;P&gt;If possible, I want to control the proximation value, like search area.&lt;/P&gt;&lt;P&gt;I've tried other suggestions in the forum: fuzzy merge and nearest rows but didn't get the results I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;would appreciate any help.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 10:37:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829453#M101151</guid>
      <dc:creator>Ohad_s</dc:creator>
      <dc:date>2025-01-28T10:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: join tables based on matched columns and closest match column</title>
      <link>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829463#M101152</link>
      <description>&lt;P&gt;Can you provide an example of the results you want?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 11:21:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829463#M101152</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-28T11:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: join tables based on matched columns and closest match column</title>
      <link>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829465#M101154</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;this is example of results i want.&lt;/P&gt;&lt;P&gt;for rows 14, 15 -&amp;nbsp;&lt;/P&gt;&lt;P&gt;if there is an option to set search area, for example 30, than this rows will be without a match and show only the reference table data.&lt;/P&gt;&lt;P&gt;but if we take the closest result regardless of search area then we will see the results as in the provided table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope it is clear&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 12:04:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829465#M101154</guid>
      <dc:creator>Ohad_s</dc:creator>
      <dc:date>2025-01-28T12:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: join tables based on matched columns and closest match column</title>
      <link>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829479#M101158</link>
      <description>&lt;P&gt;This might give some idea&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt_scan = Open("$DOWNLOADS/scan sorted.jmp");
dt_ref = Open("$DOWNLOADS/reference sorted.jmp");

dt_scan &amp;lt;&amp;lt; clear select &amp;lt;&amp;lt; Clear Column Selection;
dt_ref &amp;lt;&amp;lt; clear select &amp;lt;&amp;lt; Clear Column Selection;

dt_res = dt_ref &amp;lt;&amp;lt; Join(
	With(dt_scan),
	By Matching Columns(:Col_Reference = :Col_Scan, :Row_Reference = :Row_Scan),
	Drop multiples(0, 0),
	Include Nonmatches(1, 0),
	Preserve main table order(1),
	Output Table("Join of reference sorted with scan sorted")
);

dt_res &amp;lt;&amp;lt; New Column("Distance", Numeric, Continuous, Formula(
	Sqrt(
		(:X_Coordinates_Scan - :X_Coordinates_Reference)^2
		+
		(:Y_Coordinates_Scan - :Y_Coordinates_Reference)^2
	);
));

dt_res &amp;lt;&amp;lt; Select Where(
	:Distance == Col Min(:Distance, :Col_Reference, :Row_Reference, :ID_Reference)
	| Is Missing(:ID_SCAN)
);
dt_res &amp;lt;&amp;lt; Invert Row Selection;
dt_res &amp;lt;&amp;lt; Delete Rows;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jan 2025 13:48:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829479#M101158</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-28T13:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: join tables based on matched columns and closest match column</title>
      <link>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829494#M101161</link>
      <description>&lt;P&gt;thanks for the quick replay.&lt;/P&gt;&lt;P&gt;this works great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried to add a statement-&amp;nbsp; if :Distance &amp;lt;30 don't show the results, only the reference.&lt;/P&gt;&lt;P&gt;but ended without the results where distance &amp;gt;30.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there an option to add this condition ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 15:01:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829494#M101161</guid>
      <dc:creator>Ohad_s</dc:creator>
      <dc:date>2025-01-28T15:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: join tables based on matched columns and closest match column</title>
      <link>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829495#M101162</link>
      <description>&lt;P&gt;How did you try to add it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Script first picks the rows with the minimum distances for each of the groups and rows which couldn't be joined&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt_res &amp;lt;&amp;lt; Select Where(
	:Distance == Col Min(:Distance, :Col_Reference, :Row_Reference, :ID_Reference)
	| Is Missing(:ID_SCAN)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then it will invert the selection and remove those inverted rows&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt_res &amp;lt;&amp;lt; Invert Row Selection;
dt_res &amp;lt;&amp;lt; Delete Rows;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can either modify the selection condition to work without inverse or think how you would take the inversion into account with your distance limit.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 15:12:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/join-tables-based-on-matched-columns-and-closest-match-column/m-p/829495#M101162</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-28T15:12:23Z</dc:date>
    </item>
  </channel>
</rss>

