<?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 Divide column by value from another table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Divide-column-by-value-from-another-table/m-p/253452#M49754</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need your help to devide&amp;nbsp; columns by a variable from another table&lt;/P&gt;&lt;P&gt;dt is a big table with a lot of columns&lt;/P&gt;&lt;P&gt;dt2 has 2 columns "Names" (contains&amp;nbsp;column names&amp;nbsp;from dt) &amp;nbsp;and "DivideValue"&amp;nbsp; ( could be 10, 100, 10000,...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to divide dt columns by the dt2 Dividevalue IF dt column nane&amp;nbsp; = dt2 Names.&lt;/P&gt;&lt;P&gt;I could create a new column with formula, then remove property and delete "old column", but I guess we could apply a formula to the curent columns ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found that we can apply a custom format like below&amp;nbsp;: A/&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Column(&amp;nbsp;"A" ) &amp;lt;&amp;lt; set Format( "Custom", Formula( (value/&lt;STRONG&gt;10&lt;/STRONG&gt;)) ), 5, 0 );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in the for loop I cannot make it working.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colnamedt = {};	
N = N Col(dt);
R = N Row(dt2);
	
For(k = 1, k &amp;lt;= N, k++,
	colnamedt = Column( dt,k ) &amp;lt;&amp;lt; getname();
	for (i=1, i &amp;lt;= R, i++,
		if (( dt2:Names[i]==colname),
	     Column( dt,k ) &amp;lt;&amp;lt; set Format( "Custom", Formula( (value/dt2:DivideValue[i]) ), 5, 0 );
		););
     );&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;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Geof&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2742"&gt;@martindemel&lt;/a&gt;&amp;nbsp;&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, 20 Mar 2020 16:33:13 GMT</pubDate>
    <dc:creator>geoff1</dc:creator>
    <dc:date>2020-03-20T16:33:13Z</dc:date>
    <item>
      <title>Divide column by value from another table</title>
      <link>https://community.jmp.com/t5/Discussions/Divide-column-by-value-from-another-table/m-p/253452#M49754</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need your help to devide&amp;nbsp; columns by a variable from another table&lt;/P&gt;&lt;P&gt;dt is a big table with a lot of columns&lt;/P&gt;&lt;P&gt;dt2 has 2 columns "Names" (contains&amp;nbsp;column names&amp;nbsp;from dt) &amp;nbsp;and "DivideValue"&amp;nbsp; ( could be 10, 100, 10000,...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to divide dt columns by the dt2 Dividevalue IF dt column nane&amp;nbsp; = dt2 Names.&lt;/P&gt;&lt;P&gt;I could create a new column with formula, then remove property and delete "old column", but I guess we could apply a formula to the curent columns ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found that we can apply a custom format like below&amp;nbsp;: A/&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Column(&amp;nbsp;"A" ) &amp;lt;&amp;lt; set Format( "Custom", Formula( (value/&lt;STRONG&gt;10&lt;/STRONG&gt;)) ), 5, 0 );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in the for loop I cannot make it working.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colnamedt = {};	
N = N Col(dt);
R = N Row(dt2);
	
For(k = 1, k &amp;lt;= N, k++,
	colnamedt = Column( dt,k ) &amp;lt;&amp;lt; getname();
	for (i=1, i &amp;lt;= R, i++,
		if (( dt2:Names[i]==colname),
	     Column( dt,k ) &amp;lt;&amp;lt; set Format( "Custom", Formula( (value/dt2:DivideValue[i]) ), 5, 0 );
		););
     );&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;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Geof&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2742"&gt;@martindemel&lt;/a&gt;&amp;nbsp;&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, 20 Mar 2020 16:33:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Divide-column-by-value-from-another-table/m-p/253452#M49754</guid>
      <dc:creator>geoff1</dc:creator>
      <dc:date>2020-03-20T16:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Divide column by value from another table</title>
      <link>https://community.jmp.com/t5/Discussions/Divide-column-by-value-from-another-table/m-p/253454#M49755</link>
      <description>&lt;P&gt;JMP can directly reference any specific cell in any open JMP data table, therefore, performing your request is fairly simple&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Data Table( "dt" );
dt2 = Data Table( "dt2" );

For( i = 1, i &amp;lt;= N Rows( dt2 ), i++,
	If( Try( Column( dt, dt2:Names[i] ) &amp;lt;&amp;lt; get name, "" ) != "",
		For( k = 1, k &amp;lt; N Rows( dt ), k++,
			Column( dt, dt2:Names[i] )[k] = Column( dt, dt2:Names[i] )[k] / dt2:Divide Value[i]
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Mar 2020 16:54:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Divide-column-by-value-from-another-table/m-p/253454#M49755</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-03-20T16:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Divide column by value from another table</title>
      <link>https://community.jmp.com/t5/Discussions/Divide-column-by-value-from-another-table/m-p/253696#M49813</link>
      <description>Thank you !!!</description>
      <pubDate>Mon, 23 Mar 2020 08:51:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Divide-column-by-value-from-another-table/m-p/253696#M49813</guid>
      <dc:creator>geoff1</dc:creator>
      <dc:date>2020-03-23T08:51:51Z</dc:date>
    </item>
  </channel>
</rss>

