<?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: JSL: Differences in Column Reference Behavior in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-Differences-in-Column-Reference-Behavior/m-p/45020#M25717</link>
    <description>&lt;P&gt;Update: just realized that Method #3 will work if using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Print(NRows(dt&amp;lt;&amp;lt;GetRowsWhere(IsMissing(Column(dt, "ColName")[]))));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still feels like odd behavior to me. If &lt;EM&gt;ref = Column(dt, "ColName")&lt;/EM&gt; returns a column reference, why do I need [] here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would expect the opposite -- since &lt;EM&gt;ref = dt:ColName&lt;/EM&gt; only returns the first value in the column, I would expect to need to use [] in the &lt;EM&gt;GetRowsWhere(IsMissing(dt:ColName[])) &lt;/EM&gt;statement, and since Column(dt, "ColName") already returns a whole column, why is [] necessary?&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2017 15:46:23 GMT</pubDate>
    <dc:creator>ABI</dc:creator>
    <dc:date>2017-09-22T15:46:23Z</dc:date>
    <item>
      <title>JSL: Differences in Column Reference Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Differences-in-Column-Reference-Behavior/m-p/45018#M25715</link>
      <description>&lt;P&gt;Goal:&amp;nbsp;count how many rows of a column have empty values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Method 1 (works):&lt;/U&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = CurrentDataTable();
Print(NRows(dt&amp;lt;&amp;lt;GetRowsWhere(IsMissing(dt:ColName))));&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;&lt;U&gt;Method 2 (works):&lt;/U&gt;&lt;/P&gt;&lt;PRE&gt;&lt;U&gt;&lt;CODE class=" language-jsl"&gt;Print(NRows(dt&amp;lt;&amp;lt;GetRowsWhere(IsMissing(dt:Name("ColName")))));&lt;/CODE&gt;&lt;/U&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Method&amp;nbsp;3 (doesn't work):&lt;/U&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Print(NRows(dt&amp;lt;&amp;lt;GetRowsWhere(IsMissing(Column(dt, "ColName")))));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The error returned by debugger for&amp;nbsp;Method&amp;nbsp;3 is &lt;EM&gt;"argument should be numeric{1} in access or evaluation of 'Is Missing' , Is Missing/*###*/(Column( dt, "ColName" ))"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, it's pretty easy to understand that referencing a column by dt:ColName is identical to dt:Name("ColName"), but I'm confused as to why Column(dt, "ColName") performs differently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition, if I were to do the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ref1 = dt:ColName;
ref2 = dt:Name("ColName");
ref3 = Column(dt, "ColName");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then I get ref1 and ref2 holding a single numerical value (corresponding to the first value in the column), whereas ref3 is a reference to an appropriate Column object (as I would have expected all three declarations to accomplish).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ref1 and ref2 results seems especially odd to me -- Method #1 and #2 above were&amp;nbsp;returning the correct number of empty&amp;nbsp;cells in the column, so obviously in those implementation of the reference it wasn't just looking at the first value in the column.&amp;nbsp;It appears&amp;nbsp;what is happening is that&amp;nbsp;when dt:ColName is being set to a variable,&amp;nbsp;it's unacceptable to use the entirety of dt:ColName and it's instead choosing to&amp;nbsp;set the variable&amp;nbsp;to dt:ColName[1].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why have this&amp;nbsp;behavior?&amp;nbsp;When I&amp;nbsp;use &lt;EM&gt;ref = dt:ColName&lt;/EM&gt;, I would expect it to either return the same column&amp;nbsp;reference generated by &lt;EM&gt;ref = Column(dt, "ColName")&lt;/EM&gt; or perhaps a matrix/list full of values that correspond to the contents of the column&amp;nbsp;in the order in which they appear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, my questions boil down to (1) why do these behave differently, (2) is there an easy way to identify when dt:ColName needs to be used, and when Column(dt, "ColName") needs to be used, and (3) why does &lt;EM&gt;ref1 = dt:CFU&amp;nbsp;&lt;/EM&gt;return a reference to the first value in the column instead of either a&amp;nbsp;reference to the column itself or a fully populated matrix/list that corresponds to all values in the column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 15:38:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Differences-in-Column-Reference-Behavior/m-p/45018#M25715</guid>
      <dc:creator>ABI</dc:creator>
      <dc:date>2017-09-22T15:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: Differences in Column Reference Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Differences-in-Column-Reference-Behavior/m-p/45020#M25717</link>
      <description>&lt;P&gt;Update: just realized that Method #3 will work if using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Print(NRows(dt&amp;lt;&amp;lt;GetRowsWhere(IsMissing(Column(dt, "ColName")[]))));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still feels like odd behavior to me. If &lt;EM&gt;ref = Column(dt, "ColName")&lt;/EM&gt; returns a column reference, why do I need [] here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would expect the opposite -- since &lt;EM&gt;ref = dt:ColName&lt;/EM&gt; only returns the first value in the column, I would expect to need to use [] in the &lt;EM&gt;GetRowsWhere(IsMissing(dt:ColName[])) &lt;/EM&gt;statement, and since Column(dt, "ColName") already returns a whole column, why is [] necessary?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 15:46:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Differences-in-Column-Reference-Behavior/m-p/45020#M25717</guid>
      <dc:creator>ABI</dc:creator>
      <dc:date>2017-09-22T15:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: Differences in Column Reference Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Differences-in-Column-Reference-Behavior/m-p/45024#M25721</link>
      <description>&lt;P&gt;It will also work with &lt;STRONG&gt;AS COLUMN&lt;/STRONG&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Print(NRows(dt&amp;lt;&amp;lt;GetRowsWhere(IsMissing(as Column(dt, "ColName")))));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Sep 2017 16:21:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Differences-in-Column-Reference-Behavior/m-p/45024#M25721</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-09-22T16:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: Differences in Column Reference Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Differences-in-Column-Reference-Behavior/m-p/45033#M25728</link>
      <description>&lt;P&gt;The reason [] is needed is because Get Rows Where relies on the current row. Using Column("X")[] refers to the current row of column "X" and is equivalent to Column("X")[Row()].&lt;/P&gt;
&lt;P&gt;As &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4550"&gt;@pmroz&lt;/a&gt;&amp;nbsp;said, AsColumn("X") will work because it returns a reference to the column at the current row.&lt;/P&gt;
&lt;P&gt;Messages such as Get Rows Where and Select Where depend on the current row, in addition to For Each Row loops and column formulas.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 19:08:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Differences-in-Column-Reference-Behavior/m-p/45033#M25728</guid>
      <dc:creator>Justin_Chilton</dc:creator>
      <dc:date>2017-09-22T19:08:19Z</dc:date>
    </item>
  </channel>
</rss>

