<?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: Merge data tables in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442074#M69027</link>
    <description>&lt;P&gt;This is a fairly simple thing to do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do this interactively you would&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Open both data tables&lt;/LI&gt;
&lt;LI&gt;Go to table one and create a new column called "subcount" with the following formula
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
			Row() == 1, x = 1,
			Lag( :Batch no. 1 ) == :Batch no. 1, x++,
			x = 1
		);
		x;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;Go to the second table and create a new column also called "subcount"&amp;nbsp; with a slightly different formula, because of the different column names in the second table
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
			Row() == 1, x = 1,
			Lag( :Batch no_2 ) == :Batch no_2, x++,
			x = 1
		);
		x;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;Click on the first data table to make it the active table&lt;/LI&gt;
&lt;LI&gt;Go to&amp;nbsp; &amp;nbsp; &amp;nbsp; Tables=&amp;gt;Update
&lt;OL&gt;
&lt;LI&gt;Select the second table as the table to get the updates from&lt;/LI&gt;
&lt;LI&gt;Select column Batch no. 1 from the first table and column Batch no_2 from the second column to match on&lt;/LI&gt;
&lt;LI&gt;Select column subcount from the first table and column subcount from the second data table as the second pair of columns to match on&lt;/LI&gt;
&lt;LI&gt;Click on OK&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;Click on the column header for column subcount and then right click and select delete column&lt;/LI&gt;
&lt;LI&gt;Repeat the above step for the second data table&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Below is a script that will perform the same actions as the interactive steps above&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt1 = Data Table( "untitled 22" );
dt2 = Data Table( "untitled 23" );

dt1 &amp;lt;&amp;lt; New Column( "subcount",
	formula(
		If(
			Row() == 1, x = 1,
			Lag( :Batch no. 1 ) == :Batch no. 1, x++,
			x = 1
		);
		x;
	)
);

dt2 &amp;lt;&amp;lt; New Column( "subcount",
	formula(
		If(
			Row() == 1, x = 1,
			Lag( :Batch no_2 ) == :Batch no_2, x++,
			x = 1
		);
		x;
	)
);

dt1 &amp;lt;&amp;lt; Update( With( dt2 ), Match Columns( :Batch no. 1 = :Batch no_2, :subcount = :subcount ) );

dt1 &amp;lt;&amp;lt; delete column(subcount);
dt2 &amp;lt;&amp;lt; delete column(subcount);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Dec 2021 08:25:08 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2021-12-03T08:25:08Z</dc:date>
    <item>
      <title>Merge data tables</title>
      <link>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442022#M69021</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I need to add the data in the column "Result_test2" from the table "Untitled 23" to a new column in the table "Untitled 22". The data must be arranged as shown in the table "Untitled 27". For each batch in the first table ("Untitled 22") there are 10 data points per batch, but in the second table ("Untitled 23") there are only 3 data points per batch. I have tried various possibilities with the JOIN function, but it does not give me what I need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MBL_0-1638515827730.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38118i0C6EDDEE95051C92/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MBL_0-1638515827730.jpeg" alt="MBL_0-1638515827730.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Help is greatly appreciated&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:41:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442022#M69021</guid>
      <dc:creator>MBL</dc:creator>
      <dc:date>2023-06-10T23:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data tables</title>
      <link>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442051#M69024</link>
      <description>&lt;P&gt;Add grouping row order column to both of tables:&lt;/P&gt;&lt;P&gt;Untitled 22:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(1, :Batch no. 1)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Untitled 23:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(1, :Batch no_2)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1638518793772.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38120i4A8A805FFB669713/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1638518793772.png" alt="jthi_0-1638518793772.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1638518798231.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38121i5FB5A5B6F43B02D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1638518798231.png" alt="jthi_1-1638518798231.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Join with something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1638518844706.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38122iE1D4C5BE390C31F7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1638518844706.png" alt="jthi_2-1638518844706.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_3-1638518851564.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38123iD56B548309CF268C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1638518851564.png" alt="jthi_3-1638518851564.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Remove extra columns:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_4-1638518870770.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38124i13ECF771022E679E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_4-1638518870770.png" alt="jthi_4-1638518870770.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 08:09:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442051#M69024</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-12-03T08:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data tables</title>
      <link>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442074#M69027</link>
      <description>&lt;P&gt;This is a fairly simple thing to do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do this interactively you would&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Open both data tables&lt;/LI&gt;
&lt;LI&gt;Go to table one and create a new column called "subcount" with the following formula
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
			Row() == 1, x = 1,
			Lag( :Batch no. 1 ) == :Batch no. 1, x++,
			x = 1
		);
		x;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;Go to the second table and create a new column also called "subcount"&amp;nbsp; with a slightly different formula, because of the different column names in the second table
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
			Row() == 1, x = 1,
			Lag( :Batch no_2 ) == :Batch no_2, x++,
			x = 1
		);
		x;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;Click on the first data table to make it the active table&lt;/LI&gt;
&lt;LI&gt;Go to&amp;nbsp; &amp;nbsp; &amp;nbsp; Tables=&amp;gt;Update
&lt;OL&gt;
&lt;LI&gt;Select the second table as the table to get the updates from&lt;/LI&gt;
&lt;LI&gt;Select column Batch no. 1 from the first table and column Batch no_2 from the second column to match on&lt;/LI&gt;
&lt;LI&gt;Select column subcount from the first table and column subcount from the second data table as the second pair of columns to match on&lt;/LI&gt;
&lt;LI&gt;Click on OK&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;Click on the column header for column subcount and then right click and select delete column&lt;/LI&gt;
&lt;LI&gt;Repeat the above step for the second data table&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Below is a script that will perform the same actions as the interactive steps above&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt1 = Data Table( "untitled 22" );
dt2 = Data Table( "untitled 23" );

dt1 &amp;lt;&amp;lt; New Column( "subcount",
	formula(
		If(
			Row() == 1, x = 1,
			Lag( :Batch no. 1 ) == :Batch no. 1, x++,
			x = 1
		);
		x;
	)
);

dt2 &amp;lt;&amp;lt; New Column( "subcount",
	formula(
		If(
			Row() == 1, x = 1,
			Lag( :Batch no_2 ) == :Batch no_2, x++,
			x = 1
		);
		x;
	)
);

dt1 &amp;lt;&amp;lt; Update( With( dt2 ), Match Columns( :Batch no. 1 = :Batch no_2, :subcount = :subcount ) );

dt1 &amp;lt;&amp;lt; delete column(subcount);
dt2 &amp;lt;&amp;lt; delete column(subcount);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Dec 2021 08:25:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442074#M69027</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-12-03T08:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data tables</title>
      <link>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442122#M69034</link>
      <description>&lt;P&gt;It works. Thank you very much. Incredible how something so complex for one, can be so simple for another.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 09:25:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442122#M69034</guid>
      <dc:creator>MBL</dc:creator>
      <dc:date>2021-12-03T09:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data tables</title>
      <link>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442123#M69035</link>
      <description>&lt;P&gt;I tested this solution also and it gives the needed result also - with the script just faster. Thank you to you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 09:27:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Merge-data-tables/m-p/442123#M69035</guid>
      <dc:creator>MBL</dc:creator>
      <dc:date>2021-12-03T09:27:13Z</dc:date>
    </item>
  </channel>
</rss>

