<?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: 53 Time columns, some empty and some filled. How do I write a formula ensuring the highest filled column is &amp;gt; than next filled column etc. in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421458#M67031</link>
    <description>&lt;P&gt;I am not exactly sure that this is what you want, but the script below scans across the columns and makes sure that all date values are increasing from the previous date.&amp;nbsp; If not, it places the name of the column that has detected an earlier date than the previous date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
If( Try( dt:flag &amp;lt;&amp;lt; get name, "" ) == "",
	dt &amp;lt;&amp;lt; New Column( "Flag", Character )
);
For( rowNum = 1, rowNum &amp;lt;= N Rows( dt ), rowNum++,
	For( startCol = 1, startCol &amp;lt;= N Cols( dt ), startCol++,
		If( Is Missing( Column( startCol )[rowNum] ) == 0,
			holdVal = Column( startCol )[rowNum];
			Break();
		)
	);
	For( col = startCol + 1, col &amp;lt;= N Cols( dt ) - 1, col++,
		If( Is Missing( Column( Col )[rowNum] ) == 0,
			If( Column( Col )[rowNum] &amp;lt; holdVal,
				dt:Flag[rowNum] = (Column( Col )) &amp;lt;&amp;lt; get name;
				holdVal = Column( col )[rowNum];
				
				Break();
			,
				holdVal = Column( Col )[rowNum]
			)
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Sep 2021 22:10:36 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2021-09-27T22:10:36Z</dc:date>
    <item>
      <title>53 Time columns, some empty and some filled. How do I write a formula ensuring the highest filled column is &gt; than next filled column etc.</title>
      <link>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421443#M67026</link>
      <description>&lt;P&gt;If I have hundreds of rows, each row is a separate work ticket, each row can have up to 53 time columns filled in, but most only have some of these columns filled in and ones in between are blank.&lt;/P&gt;&lt;P&gt;So say for Row #1: I have&amp;nbsp;column 1, column 23 and column 36 are the only columns containing a time stamp, I will need know that 36&amp;gt;23 and 23&amp;gt;1.&lt;/P&gt;&lt;P&gt;For Row #2 all columns have time stamps so I will need to know that [53&amp;gt;52,............,2&amp;gt;1].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fiona&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:37:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421443#M67026</guid>
      <dc:creator>fionaweston</dc:creator>
      <dc:date>2023-06-10T23:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: 53 Time columns, some empty and some filled. How do I write a formula ensuring the highest filled column is &gt; than next filled column etc.</title>
      <link>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421444#M67027</link>
      <description>&lt;P&gt;Just to clarify; They should all be correct so I'm thinking the easiest way is to have a flagging column that will display a "1" at end of any row where above is not the case.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 20:25:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421444#M67027</guid>
      <dc:creator>fionaweston</dc:creator>
      <dc:date>2021-09-27T20:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: 53 Time columns, some empty and some filled. How do I write a formula ensuring the highest filled column is &gt; than next filled column etc.</title>
      <link>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421458#M67031</link>
      <description>&lt;P&gt;I am not exactly sure that this is what you want, but the script below scans across the columns and makes sure that all date values are increasing from the previous date.&amp;nbsp; If not, it places the name of the column that has detected an earlier date than the previous date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
If( Try( dt:flag &amp;lt;&amp;lt; get name, "" ) == "",
	dt &amp;lt;&amp;lt; New Column( "Flag", Character )
);
For( rowNum = 1, rowNum &amp;lt;= N Rows( dt ), rowNum++,
	For( startCol = 1, startCol &amp;lt;= N Cols( dt ), startCol++,
		If( Is Missing( Column( startCol )[rowNum] ) == 0,
			holdVal = Column( startCol )[rowNum];
			Break();
		)
	);
	For( col = startCol + 1, col &amp;lt;= N Cols( dt ) - 1, col++,
		If( Is Missing( Column( Col )[rowNum] ) == 0,
			If( Column( Col )[rowNum] &amp;lt; holdVal,
				dt:Flag[rowNum] = (Column( Col )) &amp;lt;&amp;lt; get name;
				holdVal = Column( col )[rowNum];
				
				Break();
			,
				holdVal = Column( Col )[rowNum]
			)
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Sep 2021 22:10:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421458#M67031</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-09-27T22:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: 53 Time columns, some empty and some filled. How do I write a formula ensuring the highest filled column is &gt; than next filled column etc.</title>
      <link>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421482#M67036</link>
      <description>&lt;P&gt;This is great, even better than what I was asking for because it tells me exactly where the condition is untrue.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 23:53:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421482#M67036</guid>
      <dc:creator>fionaweston</dc:creator>
      <dc:date>2021-09-27T23:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: 53 Time columns, some empty and some filled. How do I write a formula ensuring the highest filled column is &gt; than next filled column etc.</title>
      <link>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421552#M67042</link>
      <description>&lt;P&gt;Here is one possible solution using Matrices.&amp;nbsp;If no information about column name is needed, it can be made shorter by removing result_column and calculations related to it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();
result_flag = [];
result_column = {};
For Each Row(dt,
	m_all = dt[Row(), 0]; //get all values of row to matrix
	m_values = m_all[Loc(m_all)]; //remove missing values;
	start = Insert(m_values[1::N Items(m_values)-1], 0, 1); //shift right by 0 and remove last value
	end = m_values;
	//if we only want to know if any value is smaller than previous, we can just us any
	Insert Into(result_flag, Any(end - start &amp;lt; 0)); //we could stop here if we don't want to know the column name
	//but that doesn't tell us which column(s) breaks the "rule"
	idx = Loc(end - start &amp;lt; 0); //indices of value matrix which break the rule -&amp;gt; will require checking for empty
	If(N Items(idx) == 0,
		Insert Into(result_column, "");
	, //else
		breaking_col = Min(Loc(m_all, m_values[Min(idx)])); //values which break rule, we can most likely just get the first index?
		Insert Into(result_column, Column(dt, breaking_col) &amp;lt;&amp;lt; get name);
	);
);

dt &amp;lt;&amp;lt; New Column("Flag", Numeric, Nominal, Values(result_flag));
dt &amp;lt;&amp;lt; New Column("Column_Flag", Character, Nominal, Values(result_column));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could most likely be also used as a formula, but wouldn't most likely recommend as it is fairly easy to break:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column("Formula_Flag", Numeric, Nominal, Formula(
	dt = Current Data Table();
	m_all = Matrix(dt[Row(), 0]);
	m_values = m_all[Loc(m_all)];
	start = Insert(m_values[Index(1, N Items(m_values) - 1)], 0, 1);
	end = m_values;
	Any(end - start &amp;lt; 0);
));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 08:56:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421552#M67042</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-09-28T08:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: 53 Time columns, some empty and some filled. How do I write a formula ensuring the highest filled column is &gt; than next filled column etc.</title>
      <link>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421869#M67078</link>
      <description>&lt;P&gt;Jarmo,&lt;/P&gt;&lt;P&gt;This works very nicely too.&lt;/P&gt;&lt;P&gt;I have not done much with Matrices but looks interesting. I will have to go thru it and make sure I understand it.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 22:35:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/53-Time-columns-some-empty-and-some-filled-How-do-I-write-a/m-p/421869#M67078</guid>
      <dc:creator>fionaweston</dc:creator>
      <dc:date>2021-09-28T22:35:29Z</dc:date>
    </item>
  </channel>
</rss>

