<?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 retrieve number of rows for data table and a subset in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/retrieve-number-of-rows-for-data-table-and-a-subset/m-p/285234#M55060</link>
    <description>&lt;P&gt;Hi, I need to know the amount of rows that are present in the parent data table as well as the amount of rows in a filtered subset of this parent table. But when I try to retrieve both in 1 script, it only gives me the amount of rows in the parent... Can you please help?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//parent data table
dt = Open("C:\JMP\yield_analysis_script\used_data\edit1.jmp","visible");

//save value
f=Col Number(:height);

//print f
title1 = "parent";
text1 = Text Box ("column f: "||Char(f));
New Window(title1,text1);

//subset of parent
df = dt &amp;lt;&amp;lt; Data Filter(

Mode( Include( 1 ) ),
Add Filter( columns(:male_female),Where( :male_female == "M" )));

dftest = df &amp;lt;&amp;lt; subset( selected rows(1), selected columns(0));

//save value
p = Col Number(:height);

//print p
title2 = "subset";
text2 = Text Box ("column p: "||Char(p));
New Window(title2,text2);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the result I get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PhiIippe_0-1597150321714.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/26168i4056FD5A237AD383/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PhiIippe_0-1597150321714.png" alt="PhiIippe_0-1597150321714.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;f and p are both equal to 6, while I expect p to be 3 (since I filtered out half of the rows..)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone see the issue here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Philippe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:17:33 GMT</pubDate>
    <dc:creator>PhiIippe</dc:creator>
    <dc:date>2023-06-10T23:17:33Z</dc:date>
    <item>
      <title>retrieve number of rows for data table and a subset</title>
      <link>https://community.jmp.com/t5/Discussions/retrieve-number-of-rows-for-data-table-and-a-subset/m-p/285234#M55060</link>
      <description>&lt;P&gt;Hi, I need to know the amount of rows that are present in the parent data table as well as the amount of rows in a filtered subset of this parent table. But when I try to retrieve both in 1 script, it only gives me the amount of rows in the parent... Can you please help?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//parent data table
dt = Open("C:\JMP\yield_analysis_script\used_data\edit1.jmp","visible");

//save value
f=Col Number(:height);

//print f
title1 = "parent";
text1 = Text Box ("column f: "||Char(f));
New Window(title1,text1);

//subset of parent
df = dt &amp;lt;&amp;lt; Data Filter(

Mode( Include( 1 ) ),
Add Filter( columns(:male_female),Where( :male_female == "M" )));

dftest = df &amp;lt;&amp;lt; subset( selected rows(1), selected columns(0));

//save value
p = Col Number(:height);

//print p
title2 = "subset";
text2 = Text Box ("column p: "||Char(p));
New Window(title2,text2);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the result I get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PhiIippe_0-1597150321714.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/26168i4056FD5A237AD383/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PhiIippe_0-1597150321714.png" alt="PhiIippe_0-1597150321714.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;f and p are both equal to 6, while I expect p to be 3 (since I filtered out half of the rows..)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone see the issue here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Philippe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:17:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/retrieve-number-of-rows-for-data-table-and-a-subset/m-p/285234#M55060</guid>
      <dc:creator>PhiIippe</dc:creator>
      <dc:date>2023-06-10T23:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: retrieve number of rows for data table and a subset</title>
      <link>https://community.jmp.com/t5/Discussions/retrieve-number-of-rows-for-data-table-and-a-subset/m-p/285245#M55061</link>
      <description>&lt;P&gt;You are not pointing to your primary data table when you are doing your subset.&amp;nbsp; You are specifying&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dftest = df &amp;lt;&amp;lt; subset( selected rows(1), selected columns(0));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;"df" is the pointer to the data filter not the data table.&amp;nbsp; You should be specifying&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dftest = dt &amp;lt;&amp;lt; subset( selected rows(1), selected columns(0));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, a better way to find the number of rows in a data table is to use the N Rows() function, not the Col Number().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;numRowsMain = N Rows( dt );
// and/or
numRowsSub = N Rows( dftest );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Aug 2020 13:31:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/retrieve-number-of-rows-for-data-table-and-a-subset/m-p/285245#M55061</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-08-11T13:31:55Z</dc:date>
    </item>
  </channel>
</rss>

