<?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: Else Statment not returning in column formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Else-Statement-not-returning-in-column-formula/m-p/380483#M63085</link>
    <description>&lt;P&gt;If a numeric value is not found in the Regex it does not return a zero, it returns a missing value, by changing the comparisons to using IsMissing() the logic works correctly&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;current data table() &amp;lt;&amp;lt; New Column(
	"Packaging_Ct",
	Character,
	Nominal,
	formula(
		If(
			isMissing(Num( Regex( :Packaging, "\d+(?=\s+ct)" ) )) ==0, Regex( :Packaging, "\d+(?=\s+ct)" ),
			isMissing(Num( Regex( :Packaging, "\d+(?=ct)" ) )) == 0, Regex( :Packaging, "\d+(?=ct)" ),
			"bulk";
		);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Apr 2021 17:13:23 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2021-04-28T17:13:23Z</dc:date>
    <item>
      <title>Else Statement not returning in column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Else-Statement-not-returning-in-column-formula/m-p/380465#M63084</link>
      <description>&lt;P&gt;I'm creating a new column with some regex statements.&amp;nbsp; I have the tough regex bit figured out but the else statement returns &amp;lt;no data&amp;gt;?&amp;nbsp; Any ideas as to why this is?&amp;nbsp; I have several other if containing column formula of the same syntax that return the else statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The formula should return the integer directly before " ct" or "ct" or should return "bulk".&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;:Packaging&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :Packaging_Ct&lt;/P&gt;
&lt;P&gt;abso 400ct&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;400&lt;/P&gt;
&lt;P&gt;ebso 100 ct&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100&lt;/P&gt;
&lt;P&gt;fiber&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bulk&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table("MetaDataGelSplit") &amp;lt;&amp;lt; New Column(
	"Packaging_Ct",
	Character,
	Nominal,
	formula(
		If(
			Num( Regex( :Packaging, "\d+(?=\s+ct)" ) ) &amp;gt; 0, Regex( :Packaging, "\d+(?=\s+ct)" ),
			Num( Regex( :Packaging, "\d+(?=ct)" ) ) &amp;gt; 0, Regex( :Packaging, "\d+(?=ct)" ),
			"bulk"
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks in advance for the help.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:45:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Else-Statement-not-returning-in-column-formula/m-p/380465#M63084</guid>
      <dc:creator>danielrbiber</dc:creator>
      <dc:date>2023-06-09T19:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Else Statment not returning in column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Else-Statement-not-returning-in-column-formula/m-p/380483#M63085</link>
      <description>&lt;P&gt;If a numeric value is not found in the Regex it does not return a zero, it returns a missing value, by changing the comparisons to using IsMissing() the logic works correctly&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;current data table() &amp;lt;&amp;lt; New Column(
	"Packaging_Ct",
	Character,
	Nominal,
	formula(
		If(
			isMissing(Num( Regex( :Packaging, "\d+(?=\s+ct)" ) )) ==0, Regex( :Packaging, "\d+(?=\s+ct)" ),
			isMissing(Num( Regex( :Packaging, "\d+(?=ct)" ) )) == 0, Regex( :Packaging, "\d+(?=ct)" ),
			"bulk";
		);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Apr 2021 17:13:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Else-Statement-not-returning-in-column-formula/m-p/380483#M63085</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-04-28T17:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Else Statmente not returning in column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Else-Statement-not-returning-in-column-formula/m-p/380503#M63086</link>
      <description>&lt;P&gt;In addition to&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;'s advice, I try to build up the formula by starting with the basic Regex() function. That is, before applying Num(), make sure that you are getting what you need from Regex() first. Don't add unnecessary layers to the formula until you are satisfied that the lowest level is working for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, Regex() is relatively 'expensive,' so I would save the result from the first call in a variable and re-use it instead of call Regex() again with the same expression. it might make a big difference in large data tables.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 17:45:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Else-Statement-not-returning-in-column-formula/m-p/380503#M63086</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2021-04-28T17:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Else Statmente not returning in column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Else-Statement-not-returning-in-column-formula/m-p/380506#M63087</link>
      <description>&lt;P&gt;Seems like you could cut out one of the regex entirely as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;n = Regex( :Packaging, "(\d+)(?=\s*ct)", "\1");
if(ismissing(num(n)), 
	"bulk", 
	num(n)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Apr 2021 17:59:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Else-Statement-not-returning-in-column-formula/m-p/380506#M63087</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2021-04-28T17:59:21Z</dc:date>
    </item>
  </channel>
</rss>

