<?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 do I multiply two tables together in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373466#M62309</link>
    <description>&lt;P&gt;You could use a virtual join and formula columns.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Virtual join adds the blue and gold keys" style="width: 938px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31817i9125DDD5D44C4C4A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Virtual join adds the blue and gold keys" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Virtual join adds the blue and gold keys&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can link them interactively or with JSL.&lt;/P&gt;&lt;P&gt;This may be using JMP16 names with the&amp;nbsp;&amp;nbsp;&lt;CODE class=" language-jsl"&gt;:"parameter3[Type]"n&lt;/CODE&gt; syntax; you might need name(&lt;CODE class=" language-jsl"&gt;"parameter3[Type]"&lt;/CODE&gt;) instead.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// make example tables. **save them** so virtual join works.
factorDT = New Table( "Imported Data 2",
	New Column( "Type", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2] ) ),
	New Column( "parameter1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1.1, 1.2] ) ),
	New Column( "parameter2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0.8, 0.9] ) ),
	New Column( "parameter3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1.1, 0.9] ) )
);
factorDT &amp;lt;&amp;lt; save( "$temp/factor.jmp" );
dataDT = New Table( "Imported Data",
	New Column( "ID", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 4] ) ),
	New Column( "Type", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 2, 2] ) ),
	New Column( "parameter1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 4] ) ),
	New Column( "parameter2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [4, 3, 2, 1] ) ),
	New Column( "parameter3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 3, 3, 2] ) )
);
dataDT &amp;lt;&amp;lt; save( "$temp/data.jmp" );

// join the tables
factorDT:type &amp;lt;&amp;lt; Set Property( "Link ID", 1 );
dataDT:type &amp;lt;&amp;lt; Set Property( "Link Reference", Reference Table( "factor.jmp" ) );

// add formula columns
dataDT &amp;lt;&amp;lt; New Column( "p 1", Numeric, "Continuous", Format( "Best", 12 ), Formula( :"parameter1[Type]"n * :parameter1 ) );
dataDT &amp;lt;&amp;lt; New Column( "p 2", Numeric, "Continuous", Format( "Best", 12 ), Formula( :"parameter2[Type]"n * :parameter2 ) );
dataDT &amp;lt;&amp;lt; New Column( "p 3", Numeric, "Continuous", Format( "Best", 12 ), Formula( :"parameter3[Type]"n * :parameter3 ) );

// force the evaluation to complete
dataDT&amp;lt;&amp;lt;RunFormulas;&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;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Apr 2021 10:05:09 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2021-04-01T10:05:09Z</dc:date>
    <item>
      <title>How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373116#M62299</link>
      <description>&lt;P&gt;I have a big data table and a normalization factor table.&lt;/P&gt;&lt;P&gt;The data table looks like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Type&lt;/TD&gt;&lt;TD&gt;parameter1&lt;/TD&gt;&lt;TD&gt;parameter2&lt;/TD&gt;&lt;TD&gt;parameter3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;TD&gt;data&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;data&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;The normalization factor table looks like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Type&lt;/TD&gt;&lt;TD&gt;parameter1&lt;/TD&gt;&lt;TD&gt;parameter2&lt;/TD&gt;&lt;TD&gt;parameter3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;normalization factor1&lt;/TD&gt;&lt;TD&gt;normalization factor2&lt;/TD&gt;&lt;TD&gt;normalization factor3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;normalization factor4&lt;/TD&gt;&lt;TD&gt;normalization factor5&lt;/TD&gt;&lt;TD&gt;normalization factor6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;How can I multiply the first table by the second table based on type and parameter and obtain a new table like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Type&lt;/TD&gt;&lt;TD&gt;parameter1&lt;/TD&gt;&lt;TD&gt;parameter2&lt;/TD&gt;&lt;TD&gt;parameter3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;data*normalization factor1&lt;/TD&gt;&lt;TD&gt;data*normalization factor2&lt;/TD&gt;&lt;TD&gt;data*normalization factor3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;data*normalization factor1&lt;/TD&gt;&lt;TD&gt;data*normalization factor2&lt;/TD&gt;&lt;TD&gt;data*normalization factor3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;data*normalization factor4&lt;/TD&gt;&lt;TD&gt;data*normalization factor5&lt;/TD&gt;&lt;TD&gt;data*normalization factor6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;data*normalization factor4&lt;/TD&gt;&lt;TD&gt;data*normalization factor5&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;data*normalization factor6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;My raw data table is huge in both rows and columns so I want a fast solution.&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:28:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373116#M62299</guid>
      <dc:creator>Angela24996</dc:creator>
      <dc:date>2023-06-10T23:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373466#M62309</link>
      <description>&lt;P&gt;You could use a virtual join and formula columns.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Virtual join adds the blue and gold keys" style="width: 938px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31817i9125DDD5D44C4C4A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Virtual join adds the blue and gold keys" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Virtual join adds the blue and gold keys&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can link them interactively or with JSL.&lt;/P&gt;&lt;P&gt;This may be using JMP16 names with the&amp;nbsp;&amp;nbsp;&lt;CODE class=" language-jsl"&gt;:"parameter3[Type]"n&lt;/CODE&gt; syntax; you might need name(&lt;CODE class=" language-jsl"&gt;"parameter3[Type]"&lt;/CODE&gt;) instead.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// make example tables. **save them** so virtual join works.
factorDT = New Table( "Imported Data 2",
	New Column( "Type", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2] ) ),
	New Column( "parameter1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1.1, 1.2] ) ),
	New Column( "parameter2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0.8, 0.9] ) ),
	New Column( "parameter3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1.1, 0.9] ) )
);
factorDT &amp;lt;&amp;lt; save( "$temp/factor.jmp" );
dataDT = New Table( "Imported Data",
	New Column( "ID", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 4] ) ),
	New Column( "Type", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 2, 2] ) ),
	New Column( "parameter1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 4] ) ),
	New Column( "parameter2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [4, 3, 2, 1] ) ),
	New Column( "parameter3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 3, 3, 2] ) )
);
dataDT &amp;lt;&amp;lt; save( "$temp/data.jmp" );

// join the tables
factorDT:type &amp;lt;&amp;lt; Set Property( "Link ID", 1 );
dataDT:type &amp;lt;&amp;lt; Set Property( "Link Reference", Reference Table( "factor.jmp" ) );

// add formula columns
dataDT &amp;lt;&amp;lt; New Column( "p 1", Numeric, "Continuous", Format( "Best", 12 ), Formula( :"parameter1[Type]"n * :parameter1 ) );
dataDT &amp;lt;&amp;lt; New Column( "p 2", Numeric, "Continuous", Format( "Best", 12 ), Formula( :"parameter2[Type]"n * :parameter2 ) );
dataDT &amp;lt;&amp;lt; New Column( "p 3", Numeric, "Continuous", Format( "Best", 12 ), Formula( :"parameter3[Type]"n * :parameter3 ) );

// force the evaluation to complete
dataDT&amp;lt;&amp;lt;RunFormulas;&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 10:05:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373466#M62309</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-04-01T10:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373528#M62319</link>
      <description>&lt;P&gt;And if you don't need the formulas, you could consider element wise multiplication of matrices which may or may not be 'better'. On my MacBook the code below took about 15 seconds.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

nr = 10000; 	// Number of rows
nc = 10000;		// Number of Columns

dt1 = AsTable(J(nr, nc, RandomInteger(1, 20)));
dt2 = AsTable(J(nr, nc, RandomUniform(0, 1)));

m1 = dt1 &amp;lt;&amp;lt; getAsMatrix;
m2 = dt2 &amp;lt;&amp;lt; getAsMatrix;

dtFinal = AsTable(m1 :* m2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 14:22:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373528#M62319</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2021-04-01T14:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373662#M62337</link>
      <description>&lt;P&gt;Thank you for your reply. However, I have many columns and column names are complicated. Therefore I want to write a for loop to create new columns. Can you explain more on this statement?&lt;/P&gt;&lt;LI-CODE lang="jsl"&gt;Formula( :"parameter1[Type]"n * :parameter1 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I am thinking about writing a for loop like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;LI-CODE lang="markup"&gt;colnames = dataDT &amp;lt;&amp;lt; Get Column Names();
nc = ncols(dataDT);

DT = New Table("normalized", New Column("ID", values(dataDT:ID &amp;lt;&amp;lt; get values)),
	New Column("Type", values(dataDT:Type &amp;lt;&amp;lt; get values)));
For(i = 3, i&amp;lt;= nc, i++,
DT &amp;lt;&amp;lt; New Column( char( colnames[3]), Numeric, "Continuous", Format( "Best", 12 ), Formula( XXXX ) ));&lt;/LI-CODE&gt;&lt;P&gt;But I don't know how to construct the formula correctly&lt;SPAN style="font-family: inherit;"&gt;. It keeps giving me errors. Can you help me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 19:29:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373662#M62337</guid>
      <dc:creator>Angela24996</dc:creator>
      <dc:date>2021-04-01T19:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373663#M62338</link>
      <description>&lt;P&gt;Thank you, it works on a small dataset. But I have millions of rows in table 1 and only two rows in table 2. Therefore I want to avoid creating another huge table. If I can't find a better solution, I will try this method.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 19:38:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373663#M62338</guid>
      <dc:creator>Angela24996</dc:creator>
      <dc:date>2021-04-01T19:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373725#M62343</link>
      <description>&lt;P&gt;The loop is not easy; I think this will do it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// make example tables. **save them** so virtual join works.
factorDT = New Table( "Imported Data 2",
	New Column( "Type", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2] ) ),
	New Column( "parameter1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1.1, 1.2] ) ),
	New Column( "parameter2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0.8, 0.9] ) ),
	New Column( "parameter3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1.1, 0.9] ) )
);
factorDT &amp;lt;&amp;lt; save( "$temp/factor.jmp" );
dataDT = New Table( "Imported Data",
	New Column( "ID", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 4] ) ),
	New Column( "Type", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 2, 2] ) ),
	New Column( "parameter1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 4] ) ),
	New Column( "parameter2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [4, 3, 2, 1] ) ),
	New Column( "parameter3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 3, 3, 2] ) )
);
dataDT &amp;lt;&amp;lt; save( "$temp/data.jmp" );

originalColumns = dataDT&amp;lt;&amp;lt;getColumnNames("string");

// join the tables
factorDT:type &amp;lt;&amp;lt; Set Property( "Link ID", 1 );
dataDT:type &amp;lt;&amp;lt; Set Property( "Link Reference", Reference Table( "factor.jmp" ) );

// add formula columns
for(i=3,i&amp;lt;=nitems(originalColumns),i+=1,
	e = "dataDT &amp;lt;&amp;lt; New Column("
		|| "\!"" || originalColumns[i] || "_scaled\!"" // "parameter1_scaled"
		|| ", Numeric, \!"Continuous\!", Format( \!"Best\!", 12 ), Formula( dataDT:name(\!"" 
		|| originalColumns[i] || "[Type]" // this is the factor, in quotation marks, in name()
		|| "\!") * dataDT:name(\!"" 
		|| originalColumns[i] || // this is the data, in quotation marks, in name()
		"\!")))";
	// write(e,"\!n"); // dataDT &amp;lt;&amp;lt; New Column("parameter1_scaled", Numeric, "Continuous", Format( "Best", 12 ), Formula( dataDT:name("parameter1[Type]") * dataDT:name("parameter1")))
	eval(parse(e));
);
// force the evaluation to complete
dataDT&amp;lt;&amp;lt;RunFormulas;&lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;capture the original columns before adding the hidden columns with virtual join&lt;/LI&gt;&lt;LI&gt;build the expression e using \!" to escape the embedded quotation marks&lt;/LI&gt;&lt;LI&gt;use write() to debug your work, not print&lt;/LI&gt;&lt;LI&gt;&amp;lt;&amp;lt;RunFormulas is important for speed; the default background evaluation of column formulas is a lot slower&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 23:22:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373725#M62343</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-04-01T23:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373819#M62346</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I took a look at this and noticed a performance wall once the table got near the size of yours (actually, well before that.) I was able to improve things a bit once I began to process the table in "blocks" of about 10K rows by 1K columns. You could play with the size to see what works best, but these dimensions seemed to work well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This method does not create a new table--it overwrites the original... so you'd want to save the original, then save the result under a different name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script below makes a couple of assumptions, as it is just meant to illustrate the overall concept--&lt;/P&gt;
&lt;P&gt;- corresponding columns are in the same order in each table.&lt;/P&gt;
&lt;P&gt;- for p parameters, the main table has p+2 columns, and the factor table has p+1 columns. there are no other columns in either table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The actual &lt;EM&gt;&lt;STRONG&gt;processing&lt;/STRONG&gt; &lt;/EM&gt;time for a 1million row table with a thousand columns was about 40 seconds... each "block" took about 0.3 - 0.4 seconds to process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The table setup portion, to mock the tables you have, took a while... probably a couple of minutes. Currently the script is set for a smaller table... modify the lines under the //table settings comment to change this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is neither elegant nor compact, but it runs faster than anything else I could come up with (including using element-wise multiplication on the entire block at once... for some reason, iterating over the columns took about half the time.) I didn't try Craige's formula-based approach, though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The initial sort is needed to keep from having to fetch rows using where() (if you have to do that, it slows things considerably.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Brady&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 );

//set limits on block size
blockRowLimit = 1e4;
blockColLimit = 1e3;

// table setup
rowsdt1 = 1e4;
colsdt1 = 1e2;

dt1 = As Table( (1 :: rowsDt1)` || J( rowsDt1, 1, Random Integer( 1, 2 ) ) || J( rowsdt1, colsdt1, Random Uniform() ), &amp;lt;&amp;lt;invisible );
Column( dt1, 1 ) &amp;lt;&amp;lt; set name( "ID" );
Column( dt1, 2 ) &amp;lt;&amp;lt; set name( "Type" );

dt2 = As Table( [1 1, 2 2] || J( 2, colsdt1, Random Uniform() ), &amp;lt;&amp;lt;invisible );
Column( dt2, 1 ) &amp;lt;&amp;lt; set name( "Type" );
dt2 &amp;lt;&amp;lt; Delete Columns( 2 );


////processing begins here

dt1 &amp;lt;&amp;lt; sort( by( :type ), order( ascending ), replacetable );
type2Begin = Contains( dt1:type &amp;lt;&amp;lt; getasmatrix, 2 );		//row # of first occurrence of type == 2 in sorted table.

//build matrices that show where row &amp;amp; column divisions of "blocks" will be
rowBreaks = (1 :: N Row( dt1 ) :: blockRowLimit) || Matrix( type2Begin ) || Matrix( N Row( dt1 ) );
rowbreaks = rowbreaks[Rank( rowbreaks )]; //sort the matrix

colBreaks = (3 :: N Col( dt1 ) :: blockColLimit) || Matrix( N Col( dt1 ) );
colBreaks = colBreaks[Rank( colBreaks )]; //sort the matrix

nrowBreaks = N Row( rowBreaks );
ncolBreaks = N Row( colBreaks );

For( i = 1, i &amp;lt; nrowBreaks, i++,
	lowRow = rowBreaks[i];
	highRow = if ( i == nRowBreaks - 1, rowBreaks[i+1], rowBreaks[i+1] -1 ); //we don't need to subtract 1 off the last upper bound.
	rowRange = lowRow :: highRow;
	
	If( rowrange[1] &amp;lt; type2Begin, factorRow = 1, factorRow = 2); //determine which row of factors we'll work with for this row range of data
	
	For( j = 1, j &amp;lt; ncolBreaks, j++,		
		lowCol = colBreaks[j];
		highCol = if ( j == ncolBreaks - 1, colbreaks[j+1], colbreaks[j+1] -1 );  //we don't need to subtract 1 off the last upper bound.
		For( c = lowCol, c &amp;lt;= highCol, c++,
			dt1[rowRange, c] *= dt2[factorRow, c - 1]   // -1 because dt1 has an ID column while dt2 does not
		);				
	);
);

dt1 &amp;lt;&amp;lt; bring window to front;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 04:56:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/373819#M62346</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2021-04-02T04:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/374034#M62377</link>
      <description>&lt;P&gt;Thank you for the updates, I tried and it works on a trial dataset. However I do meet performance problems as pointed out by another person. Therefore I accepted his answer as the best solution.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 22:40:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/374034#M62377</guid>
      <dc:creator>Angela24996</dc:creator>
      <dc:date>2021-04-02T22:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/558225#M77160</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have two matrices to multiple together, for example, the first one is 3X4 matrix and the second is 4X2 matrix. Can anybody suggest how can perform this matrix multiplication in JMP Pro 16?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 22:18:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/558225#M77160</guid>
      <dc:creator>madhu</dc:creator>
      <dc:date>2022-10-19T22:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiply two tables together</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/558228#M77161</link>
      <description>&lt;P&gt;Here is an example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;mat1 = [ 1 2 3, 4 5 6, 7 8 9, 10 11 12];
mat2 = [1 2 3 4, 5 6 7 8, 9 10 11 12];
finalMat = mat1 * mat2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is an example where the data are in data tables&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt1 = data table("one");
dt2 = data table("two");
finalMat=dt1[0,0]*dt2[0,0];&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2022 22:30:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-multiply-two-tables-together/m-p/558228#M77161</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-10-19T22:30:53Z</dc:date>
    </item>
  </channel>
</rss>

