<?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 can get the result of the formula calculated with multiple columns directly from the computation of an array in memory? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/348009#M59897</link>
    <description>&lt;P&gt;My actual calculation is:&lt;BR /&gt;1. Calculate the minimum value according to the above requirements.&lt;BR /&gt;2. Calculate the maximum value according to the same principle.&lt;BR /&gt;3. Put the maximum/minimum value of categories 6, 7, 8 and 9 respectively.&lt;BR /&gt;4. Select the minimum value of the four ratios&lt;BR /&gt;This outputs the minimum ratio of each row to the table.Other intermediate data is not output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-01-13_18-44-29.png" style="width: 856px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29383iF86749A24EC8E1F8/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-01-13_18-44-29.png" alt="2021-01-13_18-44-29.png" /&gt;&lt;/span&gt;&lt;BR /&gt;I wrote the code in Excel's VBA.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Sub vba()
ar = Range("d2:d" &amp;amp; Cells(Rows.Count, "d").End(3).Row)
ReDim br(1 To UBound(ar), 1 To 8): ReDim cr(1 To UBound(ar), 1 To 1)
For r = 10 To UBound(ar)
    n = 99: m = 0
    For c = 0 To 8
        If ar(r - c, 1) &amp;lt; n Then n = ar(r - c, 1)
        If ar(r - c, 1) &amp;gt; m Then m = ar(r - c, 1)
        If c &amp;gt; 4 Then br(r, c - 4) = n: br(r, c) = m

    Next

Next
Cells(2, "G").Resize(UBound(br), UBound(br, 2)) = br

For r = 10 To UBound(ar)
    For c = 1 To 4
        If c = 1 Then
            cr(r, 1) = br(r, c + 4) / br(r, c)
        Else
            If br(r, c + 4) / br(r, c) &amp;lt; cr(r, 1) Then cr(r, 1) = br(r, c + 4) / br(r, c)
        End If

    Next
Next
Cells(2, "f").Resize(UBound(br), 1) = cr
End Sub&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;How do I change this VBA to JSL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jan 2021 11:00:30 GMT</pubDate>
    <dc:creator>lwx228</dc:creator>
    <dc:date>2021-01-13T11:00:30Z</dc:date>
    <item>
      <title>How can get the result of the formula calculated with multiple columns directly from the computation of an array in memory?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/347595#M59848</link>
      <description>&lt;P&gt;The requirements for calculation with the data of "Big Class.jmp" and formula are as follows:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Add column "row6" and find the minimum height from row 10 and up to 6 rows;&lt;BR /&gt;Add column "row7" and find the minimum value of the height column starting from row 10 and up to 7 rows;&lt;BR /&gt;...&lt;BR /&gt;How to find the result of "row6" -- "row9" directly by using memory array method?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=Open("$SAMPLE_DATA/Big Class.jmp");
dt&amp;lt;&amp;lt;New Column("row6",formula(if(row()&amp;gt;9,min(height[Index(Row()-6,Row())])));dt&amp;lt;&amp;lt;run formulas;Column("row6")&amp;lt;&amp;lt;deleteFormula;

dt&amp;lt;&amp;lt;New Column("row7",formula(if(row()&amp;gt;9,min(height[Index(Row()-7,Row())])));dt&amp;lt;&amp;lt;run formulas;Column("row7")&amp;lt;&amp;lt;deleteFormula;

dt&amp;lt;&amp;lt;New Column("row8",formula(if(row()&amp;gt;9,min(height[Index(Row()-8,Row())])));dt&amp;lt;&amp;lt;run formulas;Column("row8")&amp;lt;&amp;lt;deleteFormula;

dt&amp;lt;&amp;lt;New Column("row9",formula(if(row()&amp;gt;9,min(height[Index(Row()-9,Row())])));dt&amp;lt;&amp;lt;run formulas;Column("row9")&amp;lt;&amp;lt;deleteFormula;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-01-12_20-39-34.png" style="width: 677px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29369iE0EBDAA2065357B6/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-01-12_20-39-34.png" alt="2021-01-12_20-39-34.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:02:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/347595#M59848</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2023-06-09T22:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can get the result of the formula calculated with multiple columns directly from the computation of an array in memory?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/347634#M59850</link>
      <description>&lt;P&gt;If I understand correctly you want to get results for row6 to row9 directly to arrays without using formulas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is example for row6 using For Each Row with list and same calculation as Formula for column row6 has.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt=Open("$SAMPLE_DATA/Big Class.jmp");
dt&amp;lt;&amp;lt;New Column("row6",
	formula(
		if(row()&amp;gt;9,
			min(height[Index(Row()-6,Row())])
		)
	);
);
dt&amp;lt;&amp;lt;run formulas;
Column("row6")&amp;lt;&amp;lt;deleteFormula;

row6_list = {};
For each row(dt,
	Insert into(row6_list,
		If(row()&amp;gt;9,
			min(:height[Index(Row()-6,Row())])
		)
	)
);
show(row6_list);
dt &amp;lt;&amp;lt; new column("row6_l", &amp;lt;&amp;lt; set values(row6_list));&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>Tue, 12 Jan 2021 14:02:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/347634#M59850</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-01-12T14:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can get the result of the formula calculated with multiple columns directly from the computation of an array in memory?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/347707#M59860</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = current data table();

theHeight = dt:height &amp;lt;&amp;lt; get values;

row6=shape([.],40);
row7=shape([.],40);
row8=shape([.],40);
row9=shape([.],40);
row10=shape([.],40);

For(i=11,i&amp;lt;=N Rows(theHeight),i++,
	row6[i]=Min(theHeight[i-6::i]);
	row7[i]=Min(theHeight[i-7::i]);
	row8[i]=Min(theHeight[i-8::i]);
	row9[i]=Min(theHeight[i-9::i]);
	row10[i]=Min(theHeight[i-10::i]);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You must read the Scripting Guide so you can start solving these issues by yourself.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 16:11:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/347707#M59860</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-01-12T16:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: How can get the result of the formula calculated with multiple columns directly from the computation of an array in memory?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/348007#M59896</link>
      <description>&lt;P&gt;Thank Jim!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that this method is not the full memory array operation.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 10:58:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/348007#M59896</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2021-01-13T10:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can get the result of the formula calculated with multiple columns directly from the computation of an array in memory?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/348009#M59897</link>
      <description>&lt;P&gt;My actual calculation is:&lt;BR /&gt;1. Calculate the minimum value according to the above requirements.&lt;BR /&gt;2. Calculate the maximum value according to the same principle.&lt;BR /&gt;3. Put the maximum/minimum value of categories 6, 7, 8 and 9 respectively.&lt;BR /&gt;4. Select the minimum value of the four ratios&lt;BR /&gt;This outputs the minimum ratio of each row to the table.Other intermediate data is not output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-01-13_18-44-29.png" style="width: 856px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/29383iF86749A24EC8E1F8/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-01-13_18-44-29.png" alt="2021-01-13_18-44-29.png" /&gt;&lt;/span&gt;&lt;BR /&gt;I wrote the code in Excel's VBA.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Sub vba()
ar = Range("d2:d" &amp;amp; Cells(Rows.Count, "d").End(3).Row)
ReDim br(1 To UBound(ar), 1 To 8): ReDim cr(1 To UBound(ar), 1 To 1)
For r = 10 To UBound(ar)
    n = 99: m = 0
    For c = 0 To 8
        If ar(r - c, 1) &amp;lt; n Then n = ar(r - c, 1)
        If ar(r - c, 1) &amp;gt; m Then m = ar(r - c, 1)
        If c &amp;gt; 4 Then br(r, c - 4) = n: br(r, c) = m

    Next

Next
Cells(2, "G").Resize(UBound(br), UBound(br, 2)) = br

For r = 10 To UBound(ar)
    For c = 1 To 4
        If c = 1 Then
            cr(r, 1) = br(r, c + 4) / br(r, c)
        Else
            If br(r, c + 4) / br(r, c) &amp;lt; cr(r, 1) Then cr(r, 1) = br(r, c + 4) / br(r, c)
        End If

    Next
Next
Cells(2, "f").Resize(UBound(br), 1) = cr
End Sub&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;How do I change this VBA to JSL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 11:00:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/348009#M59897</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2021-01-13T11:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can get the result of the formula calculated with multiple columns directly from the computation of an array in memory?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/348518#M59948</link>
      <description>&lt;P&gt;As my English reading ability is limited, I can only use ready-made examples for reference.&lt;/P&gt;
&lt;P&gt;The answer is found in this example.&amp;nbsp;&lt;LI-MESSAGE title="Replacing Matrix Values" uid="217062" url="https://community.jmp.com/t5/Discussions/Replacing-Matrix-Values/m-p/217062#U217062" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks Experts!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 13:16:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-get-the-result-of-the-formula-calculated-with-multiple/m-p/348518#M59948</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2021-01-14T13:16:55Z</dc:date>
    </item>
  </channel>
</rss>

