<?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: need help identifying first nonzero column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/need-help-identifying-first-nonzero-column/m-p/48562#M27619</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1701"&gt;@dale_lehman&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;Couple of thoughts and solutions here to your problem .&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Approach 1 : Continue with JSL from previous solution and add it to table&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
Mat = dt &amp;lt;&amp;lt; Get As Matrix;  
DesList = list(); 
for(i = 1 , i &amp;lt;= N Rows(Mat), i++, 
		Pos = Min(Loc(Mat[i,0])); 
		Insert Into(DesList,Pos);
   );

dt &amp;lt;&amp;lt; New Column("Test",Numeric,Continuous,&amp;lt;&amp;lt; Set Values(DesList));

// Please note that there will be "." missing value if none of your columns have a positive value &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Approach 2 : Script the formula in JSL and apply it to the table - a little roundabout - but scaleable - an old but relevant example - will edit later in the day&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;for(i = 1, i &amp;lt;= N Items(InvColNames), i++,
							If(i == 1,
									Stmt = ":" || InvColNames[i] || " &amp;gt;= 1 &amp;amp;" || ":" || InvColNames[i] || " &amp;lt;= InvLimit" ;
									,
									Stmt = Stmt || " &amp;amp; " || ":" || InvColNames[i] || "&amp;gt;= 1 &amp;amp;" || ":" || InvColNames[i] || " &amp;lt;= InvLimit"  ; 
							  ) ;
					   );
					   
					Eval( Parse( Eval Insert("\[ dt_Inp &amp;lt;&amp;lt; New Column("Status_Inv",Numeric,Continuous,Formula(^Stmt^)); ]\" ) ) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Approach 3 :&amp;nbsp; Manually do something like this - not a fan of this, but can't seem to find an alternative by myself - maybe others will have better thoughts&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
	:Column 1 &amp;gt; 0, "Column 1",
	:Column 2 &amp;gt; 0, "Column 2",
	"No Positive"
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Dec 2017 17:36:30 GMT</pubDate>
    <dc:creator>uday_guntupalli</dc:creator>
    <dc:date>2017-12-13T17:36:30Z</dc:date>
    <item>
      <title>need help identifying first nonzero column</title>
      <link>https://community.jmp.com/t5/Discussions/need-help-identifying-first-nonzero-column/m-p/48548#M27612</link>
      <description>&lt;P&gt;I have a large dataset with around 30 columns of time-dated financial entries.&amp;nbsp; I want to know which column is the first with a nonzero (no columns have missing data, but I want to get the first column with a positive value entry) value.&amp;nbsp; I've attached a small made-up example with four time columns and a fifth column showing what I'd like my formula to result in.&amp;nbsp; If the zero values were missing, I could use the function for Number (number of nonmissing values) to get what I want, but when there is no missing data and zero values, I can't figure out how to automate identifying which column is the first that has a positive value.&amp;nbsp; Any ideas will be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 16:06:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/need-help-identifying-first-nonzero-column/m-p/48548#M27612</guid>
      <dc:creator>dale_lehman</dc:creator>
      <dc:date>2017-12-13T16:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: need help identifying first nonzero column</title>
      <link>https://community.jmp.com/t5/Discussions/need-help-identifying-first-nonzero-column/m-p/48550#M27613</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1701"&gt;@dale_lehman&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Maybe try this ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
Mat = dt &amp;lt;&amp;lt; Get As Matrix;  
DesList = list(); 
for(i = 1 , i &amp;lt;= N Rows(Mat), i++, 
		Pos = Min(Loc(Mat[i,0])); 
		Insert Into(DesList,Pos);
   );
Show(DesList); &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Dec 2017 16:15:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/need-help-identifying-first-nonzero-column/m-p/48550#M27613</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2017-12-13T16:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: need help identifying first nonzero column</title>
      <link>https://community.jmp.com/t5/Discussions/need-help-identifying-first-nonzero-column/m-p/48560#M27617</link>
      <description>&lt;P&gt;Thank you - this indeed computes what I want, but I need a bit more help (due to my almost nonexistent JSL abilities).&amp;nbsp; I can see the correct calculations in the log window, but when I enter your script into the formula window for a new column, I get blank values.&amp;nbsp; The warning I get concerns the Show() function.&amp;nbsp; How do I get the resulting calculations to appear in the new formula column?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 17:02:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/need-help-identifying-first-nonzero-column/m-p/48560#M27617</guid>
      <dc:creator>dale_lehman</dc:creator>
      <dc:date>2017-12-13T17:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: need help identifying first nonzero column</title>
      <link>https://community.jmp.com/t5/Discussions/need-help-identifying-first-nonzero-column/m-p/48562#M27619</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1701"&gt;@dale_lehman&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;Couple of thoughts and solutions here to your problem .&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Approach 1 : Continue with JSL from previous solution and add it to table&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
Mat = dt &amp;lt;&amp;lt; Get As Matrix;  
DesList = list(); 
for(i = 1 , i &amp;lt;= N Rows(Mat), i++, 
		Pos = Min(Loc(Mat[i,0])); 
		Insert Into(DesList,Pos);
   );

dt &amp;lt;&amp;lt; New Column("Test",Numeric,Continuous,&amp;lt;&amp;lt; Set Values(DesList));

// Please note that there will be "." missing value if none of your columns have a positive value &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Approach 2 : Script the formula in JSL and apply it to the table - a little roundabout - but scaleable - an old but relevant example - will edit later in the day&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;for(i = 1, i &amp;lt;= N Items(InvColNames), i++,
							If(i == 1,
									Stmt = ":" || InvColNames[i] || " &amp;gt;= 1 &amp;amp;" || ":" || InvColNames[i] || " &amp;lt;= InvLimit" ;
									,
									Stmt = Stmt || " &amp;amp; " || ":" || InvColNames[i] || "&amp;gt;= 1 &amp;amp;" || ":" || InvColNames[i] || " &amp;lt;= InvLimit"  ; 
							  ) ;
					   );
					   
					Eval( Parse( Eval Insert("\[ dt_Inp &amp;lt;&amp;lt; New Column("Status_Inv",Numeric,Continuous,Formula(^Stmt^)); ]\" ) ) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Approach 3 :&amp;nbsp; Manually do something like this - not a fan of this, but can't seem to find an alternative by myself - maybe others will have better thoughts&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
	:Column 1 &amp;gt; 0, "Column 1",
	:Column 2 &amp;gt; 0, "Column 2",
	"No Positive"
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Dec 2017 17:36:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/need-help-identifying-first-nonzero-column/m-p/48562#M27619</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2017-12-13T17:36:30Z</dc:date>
    </item>
  </channel>
</rss>

