<?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: Use of local variable in a formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262921#M51407</link>
    <description>Thank you!&lt;BR /&gt;</description>
    <pubDate>Thu, 30 Apr 2020 19:33:49 GMT</pubDate>
    <dc:creator>lance</dc:creator>
    <dc:date>2020-04-30T19:33:49Z</dc:date>
    <item>
      <title>Use of local variable in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262870#M51395</link>
      <description>&lt;P&gt;I have a table that has a column (Samp Pt) which lists the equipment name as Equip_n where n is 1 through 9.&lt;/P&gt;&lt;P&gt;The Column "Date / Time" is the date and time.&lt;/P&gt;&lt;P&gt;The data is sorted by Equip_n and then Date / Time.&lt;/P&gt;&lt;P&gt;I want to create a value called Run which is the Run number for each piece of Equipment.&amp;nbsp; The Run is the Equipment number-Run, e.g. 1-1.&amp;nbsp; A new Run is defined when the difference between successive rows of Date/Time is greater than 190,000 seconds.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using two local variables to keep track of the numerical value of the "n". It creates the first Run Value for each Equipment correctly ("1-1, "2-1", etc.) but when the successive rows are &amp;gt;190000 seconds apart, I get "1-.", "2-.").&amp;nbsp; I'm pretty sure that I'm not using the local variables correctly. What am I doing wrong?&amp;nbsp; Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 16:41:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262870#M51395</guid>
      <dc:creator>lance</dc:creator>
      <dc:date>2020-04-30T16:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Use of local variable in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262885#M51399</link>
      <description>&lt;P&gt;This formula appears to work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	hold = 1;
	hold2 = 1;
,
	If( :Name( "Date / Time" ) - Lag( :Name( "Date / Time" ) ) &amp;gt; 190000,
		hold2 = hold2 + 1
	);
	If( :Samp Pt != Lag( :Samp Pt ),
		hold = hold + 1;
		hold2 = 1;
	);
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Apr 2020 18:13:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262885#M51399</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-04-30T18:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Use of local variable in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262906#M51402</link>
      <description>&lt;P&gt;Thank you, but when I cut and paste your solution into the formula editor, the second and third If clauses do not have anything in the else clause. It runs but it only give the value of 1 in the first row, all others are blank.&amp;nbsp; I'm running jmp (not Pro) 14.2 if that is a factor.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 18:50:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262906#M51402</guid>
      <dc:creator>lance</dc:creator>
      <dc:date>2020-04-30T18:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Use of local variable in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262914#M51405</link>
      <description>&lt;P&gt;My error, when I pasted the formula into the response, I did not get all of the formula....I left out one line&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	hold = 1;
	hold2 = 1;
,
	If( :Name( "Date / Time" ) - Lag( :Name( "Date / Time" ) ) &amp;gt; 190000,
		hold2 = hold2 + 1
	);
	If( :Samp Pt != Lag( :Samp Pt ),
		hold = hold + 1;
		hold2 = 1;
	);
);
Char( hold ) || "-" || Char( hold2 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Apr 2020 19:09:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262914#M51405</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-04-30T19:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Use of local variable in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262921#M51407</link>
      <description>Thank you!&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Apr 2020 19:33:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-of-local-variable-in-a-formula/m-p/262921#M51407</guid>
      <dc:creator>lance</dc:creator>
      <dc:date>2020-04-30T19:33:49Z</dc:date>
    </item>
  </channel>
</rss>

