<?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: Formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Formula/m-p/839183#M101449</link>
    <description>&lt;P&gt;Doing the calculation from the original column is most likely easier&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("Column",
		Character,
		"Nominal",
		Set Values({"1-1-3", "2-2-2", "3-3", ""})
	),
	New Column("Column 1", Character, "Nominal", Set Values({"1", "2", "3", ""})),
	New Column("Column 2", Character, "Nominal", Set Values({"1", "2", "3", ""})),
	New Column("Column 3", Character, "Nominal", Set Values({"3", "2", "", ""}))
);

dt &amp;lt;&amp;lt; New Column("R", Numeric, Nominal, Formula(
	res = Associative Array(Words(:Column , "-")) &amp;lt;&amp;lt; get keys;
	Remove From(res, Contains(res, "")); // remove missing value
	N Items(res) == 1;
));&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-1739188538668.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72765i8D4B82DCF9A469D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1739188538668.png" alt="jthi_0-1739188538668.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Not sure how fully missing row should be taken into account, in this case it is treated as 0 but it can be changed to one modifying the final comparison&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2025 11:56:26 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2025-02-10T11:56:26Z</dc:date>
    <item>
      <title>Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Formula/m-p/839063#M101444</link>
      <description>&lt;P&gt;Bonjour, je cherche à construire une colonne de test :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hcarr01_0-1739172787005.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72758i7B8D2ECCB34479A4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hcarr01_0-1739172787005.png" alt="hcarr01_0-1739172787005.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A partir du script suivant :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt11 = current data table();&lt;BR /&gt;
// Choisir colonnes commençant par employes
dur_cols = Filter Each( {col_name}, dt11 &amp;lt;&amp;lt; Get Column Names( "String", Nominal ),
	Starts With( col_name, "employes " )
);

// Nouvelle colonne
dt11 &amp;lt;&amp;lt; New Column( "TEST EMPLOYES", Numeric, "Continuous", Format( "Best", 12 ) );

// Modifier la formule de colonne&amp;nbsp;: TEST EMPLOYES
dt11:TEST EMPLOYES &amp;lt;&amp;lt;
Set Formula(
	For( i = 1, i &amp;lt; n items(dur_cols), i++,
		If(
			(dur_cols[i] == dur_cols[i+1] | Is Missing( dur_cols[i+1] )),
			:TEST EMPLOYES = 1
			,
			:TEST EMPLOYES = 0
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;L'objectif est d'avoir des 0 ou des 1 dans la colonne &lt;STRONG&gt;TEST EMPLOYES&lt;/STRONG&gt; en fonction des conditions dans la boucle if... Pour le moment je n'arrive pas à créer la colonne test employes avec les valeurs 0 ou 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Merci de votre aide&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 07:35:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Formula/m-p/839063#M101444</guid>
      <dc:creator>hcarr01</dc:creator>
      <dc:date>2025-02-10T07:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Formula/m-p/839143#M101446</link>
      <description>&lt;P&gt;What are the conditions when 1 or 0 should be added?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 09:53:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Formula/m-p/839143#M101446</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-10T09:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Formula/m-p/839171#M101447</link>
      <description>&lt;P&gt;Je pars d'une colonne employé, dans laquelle il y a plusieurs champs renseigné comme par exemple "611 - 2000 - 300", il peut y avoir plus de 3 champs renseigné.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dans mon script je divise cette colonne à partir du séparateur "-", donc il y a autant de colonne "employe..." que de champs dans la première colonne "employe".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Condition TEST EMPLOYE = 1 :&lt;/P&gt;&lt;P&gt;Toutes les colonnes employés crées sont égales ou valeur manquantes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Condition TEST EMPLOYE = 0 :&lt;/P&gt;&lt;P&gt;Données différentes dans les colonnes employés crées (ne pas prendre en compte quand la colonne est vide)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Exemple 1 :&lt;/U&gt;&lt;/P&gt;&lt;P&gt;colonne employé 1 : 300&lt;/P&gt;&lt;P&gt;colonne employé 2 : 300&lt;/P&gt;&lt;P&gt;colonne employé 3 : 500&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TEST EMPLOYE = 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Exemple 2 :&lt;/U&gt;&lt;/P&gt;&lt;P&gt;colonne employé 1 : 300&lt;/P&gt;&lt;P&gt;colonne employé 2 : 300&lt;/P&gt;&lt;P&gt;colonne employé 3 :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TEST EMPLOYE = 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 10:13:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Formula/m-p/839171#M101447</guid>
      <dc:creator>hcarr01</dc:creator>
      <dc:date>2025-02-10T10:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Formula/m-p/839183#M101449</link>
      <description>&lt;P&gt;Doing the calculation from the original column is most likely easier&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("Column",
		Character,
		"Nominal",
		Set Values({"1-1-3", "2-2-2", "3-3", ""})
	),
	New Column("Column 1", Character, "Nominal", Set Values({"1", "2", "3", ""})),
	New Column("Column 2", Character, "Nominal", Set Values({"1", "2", "3", ""})),
	New Column("Column 3", Character, "Nominal", Set Values({"3", "2", "", ""}))
);

dt &amp;lt;&amp;lt; New Column("R", Numeric, Nominal, Formula(
	res = Associative Array(Words(:Column , "-")) &amp;lt;&amp;lt; get keys;
	Remove From(res, Contains(res, "")); // remove missing value
	N Items(res) == 1;
));&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-1739188538668.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72765i8D4B82DCF9A469D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1739188538668.png" alt="jthi_0-1739188538668.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Not sure how fully missing row should be taken into account, in this case it is treated as 0 but it can be changed to one modifying the final comparison&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 11:56:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Formula/m-p/839183#M101449</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-10T11:56:26Z</dc:date>
    </item>
  </channel>
</rss>

