<?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 Formula in jsl script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Formula-in-jsl-script/m-p/912570#M107231</link>
    <description>&lt;P&gt;I have single column table of numeric type, I want to add column and give a formula where it will check each cell of the first column with a variable name passed in script,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mycol &amp;lt;&amp;lt; New Column ("belowCount", Numeric, Formula(If( col_to_check &amp;lt; limit_val, 1, 0 ) );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mycol is single column data table and col_to_check is reference first column and limit_val is variable&lt;/P&gt;
&lt;P&gt;When I open table formula is not able to take the first column&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried using : Column(1), Column(1) and also used Expr function which are of no use&lt;/P&gt;</description>
    <pubDate>Tue, 11 Nov 2025 14:29:32 GMT</pubDate>
    <dc:creator>ravij</dc:creator>
    <dc:date>2025-11-11T14:29:32Z</dc:date>
    <item>
      <title>Formula in jsl script</title>
      <link>https://community.jmp.com/t5/Discussions/Formula-in-jsl-script/m-p/912570#M107231</link>
      <description>&lt;P&gt;I have single column table of numeric type, I want to add column and give a formula where it will check each cell of the first column with a variable name passed in script,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mycol &amp;lt;&amp;lt; New Column ("belowCount", Numeric, Formula(If( col_to_check &amp;lt; limit_val, 1, 0 ) );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mycol is single column data table and col_to_check is reference first column and limit_val is variable&lt;/P&gt;
&lt;P&gt;When I open table formula is not able to take the first column&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried using : Column(1), Column(1) and also used Expr function which are of no use&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2025 14:29:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Formula-in-jsl-script/m-p/912570#M107231</guid>
      <dc:creator>ravij</dc:creator>
      <dc:date>2025-11-11T14:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Formula in jsl script</title>
      <link>https://community.jmp.com/t5/Discussions/Formula-in-jsl-script/m-p/912602#M107236</link>
      <description>&lt;P&gt;Correct syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(
	Eval Expr(
		mycol &amp;lt;&amp;lt; New Column( "belowCount",
			Numeric,
			Formula( If( Expr( Name Expr( As Column( col_to_check ) ) ) &amp;lt; Expr( limit_val ), 1, 0 ) )
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2025 19:44:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Formula-in-jsl-script/m-p/912602#M107236</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-11-11T19:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Formula in jsl script</title>
      <link>https://community.jmp.com/t5/Discussions/Formula-in-jsl-script/m-p/912603#M107237</link>
      <description>&lt;P&gt;first thing, your example formula didn't have enough closing parentheses, so it may give an error for that. Second thing is that your "col_to_check" may have needed a ":" in front of it, unless it was a variable name of the column or it was exactly the same spelling and case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Below is what I was able to use that I think did what you are looking for. I used Eval and Eval Expr at the start of the new column line to evaluate the variable to create the column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

mycol = current data table();
limit_val = 5;
eval(eval expr(mycol &amp;lt;&amp;lt; New Column ("belowCount", Numeric, Formula(If( :col_to_check &amp;lt; expr(limit_val), 1, 0 ) ))));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Nov 2025 15:15:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Formula-in-jsl-script/m-p/912603#M107237</guid>
      <dc:creator>bfoulkes</dc:creator>
      <dc:date>2025-11-11T15:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Formula in jsl script</title>
      <link>https://community.jmp.com/t5/Discussions/Formula-in-jsl-script/m-p/912633#M107241</link>
      <description>&lt;P&gt;You will have to evaluate the variables to formulas . This is still a good reference&lt;LI-MESSAGE title="Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute" uid="48998" url="https://community.jmp.com/t5/JSL-Cookbook-Archived/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/m-p/48998#U48998" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;(thought it could use some updates). Here is one option using Eval(Substitute()) (for simple case like this, I would use Eval(EvalExpr()) which hogi did demonstrate)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

new_col = Eval(Substitute(
	Expr(mycol &amp;lt;&amp;lt; New Column("belowCount", Numeric, 
		Formula(If(col_to_check &amp;lt; _limit_val_, 1, 0))
	)),
	Expr(col_to_check), Name Expr(AsColumn(mycol, 1)),
	Expr(_limit_val_), limit_val
));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And full example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

limit_val = 5;

mycol = New Table("Untitled",
	Add Rows(10),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Set Values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
);

new_col = Eval(Substitute(
	Expr(mycol &amp;lt;&amp;lt; New Column("belowCount", Numeric, 
		Formula(If(col_to_check &amp;lt; _limit_val_, 1, 0))
	)),
	Expr(col_to_check), Name Expr(AsColumn(mycol, 1)),
	Expr(_limit_val_), limit_val
));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1762881464895.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/86834i2CA995483133C3B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_0-1762881464895.png" alt="jthi_0-1762881464895.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2025 17:18:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Formula-in-jsl-script/m-p/912633#M107241</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-11-11T17:18:02Z</dc:date>
    </item>
  </channel>
</rss>

