<?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 Set cell value if row is selected in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275553#M53472</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm a newbie trying to write a script to fill in a cell value if its row is selected.&amp;nbsp; The use case I have in mind is as follow: during exploratory data analysis I select some points in a graph which I suspect to be outliers.&amp;nbsp; I have another script which helps me look at the raw data (not part of the JMP table), and based on looking at that raw data I decide the row corresponding to this data point should be excluded from my analysis (i.e. the raw data used to generate that particular row is garbage).&amp;nbsp; I can simply right click and select "Exclude".&amp;nbsp; Now all my JMP analysis looks at only the good data points which is fine and dandy.&amp;nbsp; Now after I finish all this analysis I want to go back and do some analysis on the rows that I excluded.&amp;nbsp; For instance, if each row represents data collected by different operators, maybe one operator is producing a lot of junk data.&amp;nbsp; I can of course do a point and click solution to select all excluded rows and create a new subset datatable, but what I would prefer to do is add a new column (let's call it FlagColumn) and set all the selected rows in FlagColumn to "bad" and all the other rows to "good".&amp;nbsp; What I have in mind is something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();

rows =  dt &amp;lt;&amp;lt; get selected rows ;


For( i=1, 
     i&amp;lt;=5, 
     i++, 
     if(Row State(i) == Selected State(1),
     	dt:FlagColumn[i] = 0
     );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But this doesn't seem to do anything - I think I don't understand how to setup the condition in the if statement correctly.&amp;nbsp; Also, I have not yet figured out how to get the number of rows in the table (so for testing purposes at the moment I just set the index i in the for loop to run from 1 to 5).&amp;nbsp; Any suggestions?&amp;nbsp; Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:15:17 GMT</pubDate>
    <dc:creator>jdwatson</dc:creator>
    <dc:date>2023-06-10T23:15:17Z</dc:date>
    <item>
      <title>Set cell value if row is selected</title>
      <link>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275553#M53472</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm a newbie trying to write a script to fill in a cell value if its row is selected.&amp;nbsp; The use case I have in mind is as follow: during exploratory data analysis I select some points in a graph which I suspect to be outliers.&amp;nbsp; I have another script which helps me look at the raw data (not part of the JMP table), and based on looking at that raw data I decide the row corresponding to this data point should be excluded from my analysis (i.e. the raw data used to generate that particular row is garbage).&amp;nbsp; I can simply right click and select "Exclude".&amp;nbsp; Now all my JMP analysis looks at only the good data points which is fine and dandy.&amp;nbsp; Now after I finish all this analysis I want to go back and do some analysis on the rows that I excluded.&amp;nbsp; For instance, if each row represents data collected by different operators, maybe one operator is producing a lot of junk data.&amp;nbsp; I can of course do a point and click solution to select all excluded rows and create a new subset datatable, but what I would prefer to do is add a new column (let's call it FlagColumn) and set all the selected rows in FlagColumn to "bad" and all the other rows to "good".&amp;nbsp; What I have in mind is something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();

rows =  dt &amp;lt;&amp;lt; get selected rows ;


For( i=1, 
     i&amp;lt;=5, 
     i++, 
     if(Row State(i) == Selected State(1),
     	dt:FlagColumn[i] = 0
     );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But this doesn't seem to do anything - I think I don't understand how to setup the condition in the if statement correctly.&amp;nbsp; Also, I have not yet figured out how to get the number of rows in the table (so for testing purposes at the moment I just set the index i in the for loop to run from 1 to 5).&amp;nbsp; Any suggestions?&amp;nbsp; Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:15:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275553#M53472</guid>
      <dc:creator>jdwatson</dc:creator>
      <dc:date>2023-06-10T23:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Set cell value if row is selected</title>
      <link>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275560#M53474</link>
      <description>Look at make rowstste Handler</description>
      <pubDate>Fri, 26 Jun 2020 12:28:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275560#M53474</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-06-26T12:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Set cell value if row is selected</title>
      <link>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275610#M53481</link>
      <description>Hi,&lt;BR /&gt;First, it is unclear why you would define "rows = dt &amp;lt;&amp;lt; get selected rows" and not use it in the subsequent script.&lt;BR /&gt;Second, have you considered the much simpler formula: "Selected ()" which returns 1 if selected and 0 if not (i.e. set the FlagColumn formula as: "Selected ()"). Of note, like all formulas, it is evaluated automatically by default therefore you may need to toggle to Suppress Eval state in the formula dialog to retain a certain state of selection. Also, if you need to only capture the selection state once, you may add the formula, apply the change, and delete the formula which will keep a stable record of what was selected upon running the formula.</description>
      <pubDate>Fri, 26 Jun 2020 13:28:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275610#M53481</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2020-06-26T13:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Set cell value if row is selected</title>
      <link>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275611#M53482</link>
      <description>One more thing,&lt;BR /&gt;Have you considered changing the FlagColumn Data Type to "Row State" and use it to capture the current selection state (right click on the column header &amp;gt; Row States Cells &amp;gt; Select/Deselect?&lt;BR /&gt;Best,&lt;BR /&gt;&lt;BR /&gt;TS</description>
      <pubDate>Fri, 26 Jun 2020 13:33:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275611#M53482</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2020-06-26T13:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Set cell value if row is selected</title>
      <link>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275617#M53483</link>
      <description>&lt;P&gt;I think I answered my own question.&amp;nbsp; Adding it below in case others come across this problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();

rs = dt &amp;lt;&amp;lt; Get Row States;

For( i=1, 
     i&amp;lt;=Length(rs), 
     i++, 
     if(rs[i] == 1,
     	FlagColumn[i] = 1
     );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jun 2020 13:57:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275617#M53483</guid>
      <dc:creator>jdwatson</dc:creator>
      <dc:date>2020-06-26T13:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Set cell value if row is selected</title>
      <link>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275622#M53484</link>
      <description>&lt;P&gt;Ah, yes, this looks like it also accomplishes the same thing I was wanting to do, without any scripting.&amp;nbsp; It seems that the local data filter doesn't show row state columns, though.&amp;nbsp; Is there a way to configure a graph window such that it includes excluded rows and then filter using the row state?&amp;nbsp; Or now that I say this, maybe my real question is what is the simplest way to get a graph/analysis of&amp;nbsp;&lt;EM&gt;only&lt;/EM&gt; the excluded rows without creating separate subset datatables?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2020 14:09:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275622#M53484</guid>
      <dc:creator>jdwatson</dc:creator>
      <dc:date>2020-06-26T14:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Set cell value if row is selected</title>
      <link>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275785#M53517</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/19439"&gt;@jdwatson&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hmmm, to me validating data can be a task that might take more than one editing session.&amp;nbsp; Also, maybe I'm clumsy, but to me it is so easy to accidentally unselect.&amp;nbsp; Here is an alternate suggestion that comprehends&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11634"&gt;@Thierry_S&lt;/a&gt;&amp;nbsp; suggestion:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;if summary/calculated data is deemed poor quality right click and exclude&lt;/LI&gt;
&lt;LI&gt;once done validating and run the standard analyses&lt;/LI&gt;
&lt;LI&gt;create a new column, I'll call Excluded State.&amp;nbsp; Make the data type &lt;STRONG&gt;Row State,&lt;/STRONG&gt; it has a red star icon.&amp;nbsp;Now you can click on that column name and select &lt;STRONG&gt;Copy From Rowstates&lt;/STRONG&gt; see the screen shot below.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rowstateoptions.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24845iFBB057D9C0F18143/image-size/large?v=v2&amp;amp;px=999" role="button" title="rowstateoptions.png" alt="rowstateoptions.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Then create a column called Flag or Excluded make it Numeric, Nominal. Make a formula &lt;STRONG&gt;Excluded()&lt;/STRONG&gt; and select the button apply, then clear the Formula, press &lt;STRONG&gt;OK&lt;/STRONG&gt;. Now you will have a 1 in excluded rows and 0 elsewhere.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Now you can clear the row states and use this&amp;nbsp; Flag column as planned.&amp;nbsp; But you have the added benefit to quickly click on the Excluded State column and select &lt;STRONG&gt;Copy to Row States&lt;/STRONG&gt;, if you need to do further analyses on the good quality data.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Row State columns are especially nice when there is suspect data or requests for&amp;nbsp; "what if blah, blah, was removed" analyses.&amp;nbsp; You can keep a row state for the standard exclusions and the standrd + extra exclusions.&amp;nbsp; This is a form of row state handling, that is not interactive nor dynamic, but can be quite useful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 00:52:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/275785#M53517</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2020-06-28T00:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Set cell value if row is selected</title>
      <link>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/627230#M82581</link>
      <description>&lt;P&gt;If you do not want to code and keeop it interactive, you could use Rows -&amp;gt; Row Selection -&amp;gt; Name Selection in Column . This will create a column where you have a value for the selected rows and a value (or missing) ofr the others. Kind of similar what was achieved with the scripted row state option mentioned above&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 10:12:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-cell-value-if-row-is-selected/m-p/627230#M82581</guid>
      <dc:creator>martindemel</dc:creator>
      <dc:date>2023-04-28T10:12:47Z</dc:date>
    </item>
  </channel>
</rss>

