<?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: Calcul in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Calcul/m-p/635348#M83351</link>
    <description>&lt;P&gt;I'm glad you were able to solve the problem yourself.&lt;/P&gt;</description>
    <pubDate>Thu, 25 May 2023 08:33:07 GMT</pubDate>
    <dc:creator>yuichi_katsumur</dc:creator>
    <dc:date>2023-05-25T08:33:07Z</dc:date>
    <item>
      <title>Calcul</title>
      <link>https://community.jmp.com/t5/Discussions/Calcul/m-p/633875#M83196</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Bonjour à tous,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Je cherche à construire une formule par rapport à plusieurs colonnes de ma base de données. Ce n’est pas si simple à comprendre, je vais expliquer mon objectif à l’aide d’un exemple :&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hcarr01_0-1684745786420.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/52950i285FDFB08751294F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hcarr01_0-1684745786420.png" alt="hcarr01_0-1684745786420.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;L'étape 1 correspond au numéro 2100 mais ce numéro peut avoir une opération correspondante différente en fonction des objets ( Exemple : objet 1 --&amp;gt; numéro 2100 / opération 62 , objet 5 --&amp;gt; numéro 2100 / opération 74)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;STRONG&gt;ETAPE 1 : correspond au numéro 2100&lt;/STRONG&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;U&gt;Partie grise :&lt;/U&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Ici, voici 4 type d’objet différents (ENT1,..,ENT4). Chacun des objets est associé à un numéro d’avancement (colonne T), ces numéros sont eux reliés à des opérations bien définis.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;U&gt;Partie jaune :&lt;/U&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Ces cellules montrent quels «&amp;nbsp;numéros&amp;nbsp;» vont subir chaque objet, et associe ce numéro à des opérations. Lorsque les cellules sont vides, cela veut dire que l’objet ne subira pas cette opération.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;U&gt;L’objectif est :&lt;/U&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;- Faire la somme des durées jusqu’à l’étape 1, sachant que l’objet a eu un avancement (Ex : l’objet ENT2 se situe au numéro 1749, donc ce qu’il a fait avant en 1500 ne nous intéresse pas) donc la durée jusqu’à l’étape 1 est seulement la durée de l’étape 1749 donc durée = 45&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;J’ai commencé avec ce code :&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();
dur_cols = Filter Each({col_name}, dt &amp;lt;&amp;lt; Get Column Names("String", Continuous),
	Starts With(col_name, "durée"));

// for indexing later
num_colnr = Transform Each({col_name}, dur_cols,Word(-1, col_name));

dt &amp;lt;&amp;lt; New Column("DUREE ETAPE1", Numeric, Continuous, Format(":jou:hh:m",8), &amp;lt;&amp;lt; Set Each Value(
	If( :"T"n &amp;lt; 2100 ,
		colidx = Loc(dt[Row(), num_colnr] &amp;gt; :"opé"n &amp;amp; (num_colnr &amp;lt; 2100 )  );
		If(N Items(colidx) &amp;gt; 0,
			val = Sum(dt[Row(), dur_cols[colidx]]);
			If(IsMissing(val),
				0
			,
				val
			);
		,
			0
		)
	,
		0
		)
	
));&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Merci pour votre aide,&lt;/DIV&gt;&lt;DIV&gt;Cordialement&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:10:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calcul/m-p/633875#M83196</guid>
      <dc:creator>hcarr01</dc:creator>
      <dc:date>2023-06-09T16:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calcul</title>
      <link>https://community.jmp.com/t5/Discussions/Calcul/m-p/634681#M83272</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/44672"&gt;@hcarr01&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I'm not sure I understand your request correctly, but how about the following script?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();
dur_cols = Filter Each( {col_name}, dt &amp;lt;&amp;lt; Get Column Names( "String", Continuous ),
	Starts With( col_name, "durée" )
);

// for indexing later 
num_colnr = Transform Each( {col_name}, dur_cols, Word( -1, col_name ) );
// Add : Matrix of the index
num_colnr_mt = Matrix( Transform Each( {col_name}, dur_cols, Num( Word( -1, col_name ) ) ) )`;

dt &amp;lt;&amp;lt; New Column( "DUREE ETAPE1",
	Numeric,
	Continuous,
	Format( ":jou:hh:m", 8 ),
	&amp;lt;&amp;lt;Set Each Value(
		If( :"T"n &amp;lt; 2100,
			//colidx = Loc(dt[Row(), num_colnr] &amp;gt; :"opé"n &amp;amp; (num_colnr &amp;lt; 2100 )  );
			colidx = Loc( dt[Row(), num_colnr] &amp;gt;= :"opé"n &amp;amp; (num_colnr_mt &amp;lt; 2100) ); // Changed
			If( N Items( colidx ) &amp;gt; 0,
				val = Sum( dt[Row(), dur_cols[colidx]] );
				If( Is Missing( val ),
					0,
					val
				);
			,
				0
			);
		,
			0
		)
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;If you want to calculate the following code, you need to use matrix.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt; "num_colnr &amp;lt; 2100"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I hope it helps.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 00:25:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calcul/m-p/634681#M83272</guid>
      <dc:creator>yuichi_katsumur</dc:creator>
      <dc:date>2023-05-24T00:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calcul</title>
      <link>https://community.jmp.com/t5/Discussions/Calcul/m-p/634722#M83280</link>
      <description>&lt;DIV&gt;Merci pour votre aide, le code marche correctement mais il y a un problème.&lt;/DIV&gt;&lt;DIV&gt;le but est de ne pas utiliser les nombres de la variable T tels que T &amp;lt; 2100 car pour chaque objet ce numéro possède une opération correspondante différente.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Il faudrait faire une affectation où pour chaque objet on cherche l'opération correspondante au numéro 2100 (dans la variable T).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;Pour chaque ligne, ça serait :&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Si l'opération en cours est inférieur ou égal à l'opération correspondante au numéro 2100 alors faire la somme jusqu'à l'opération correspondante au numéro 2100.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;U&gt;Exemple sur la première ligne :&lt;/U&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Opération en cours : 55&lt;/DIV&gt;&lt;DIV&gt;Opération correspondante au numéro 2100 -&amp;gt; 62&lt;/DIV&gt;&lt;DIV&gt;Donc faire la somme du numéro correspondant à l'opération 55 donc numéro 1500.&lt;/DIV&gt;&lt;DIV&gt;D'où "durée etape" = "durée 1500" = 30&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Sauf que les numéros ne sont pas rangés dans l'ordre croissant forcement.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 24 May 2023 08:08:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calcul/m-p/634722#M83280</guid>
      <dc:creator>hcarr01</dc:creator>
      <dc:date>2023-05-24T08:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calcul</title>
      <link>https://community.jmp.com/t5/Discussions/Calcul/m-p/635214#M83339</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/44672"&gt;@hcarr01&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thank you for your response.&amp;nbsp;Can I check my understanding?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example on the second line:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Operation in progress: 60 (number in column "opé")&lt;BR /&gt;Operation corresponding to number 2100 -&amp;gt; 62 (in variable T and opé)&lt;BR /&gt;So make the sum of the number corresponding to operation 60, therefore number 1749 (find number 60 in column 1500, 1749, 2100 or 2500).&lt;BR /&gt;Therefore "Duration of step" = "Durée 1749" = 45&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Example on the third row:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Operation in progress: 62 (number in the "opé" column)&lt;BR /&gt;Operation corresponding to the number 2100 -&amp;gt; 62&lt;BR /&gt;So make the sum of the number corresponding to operation 62, therefore number 2100.&lt;BR /&gt;Therefore, "Step duration" = 0 (because the current operation is greater than or equal to the operation corresponding to number 2100).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In your question you described as follows.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;"Step 1 corresponds to number 2100, but this number can have a different corresponding operation depending on the objects (example: object 1 --&amp;gt; number 2100 / operation 62, object 5 --&amp;gt; number 2100 / operation 74)".&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What does object 5 look like? Can you give us an example?&lt;/P&gt;
&lt;P&gt;If my understanding is not correct, please let me know.&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 02:35:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calcul/m-p/635214#M83339</guid>
      <dc:creator>yuichi_katsumur</dc:creator>
      <dc:date>2023-05-25T02:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Calcul</title>
      <link>https://community.jmp.com/t5/Discussions/Calcul/m-p/635286#M83346</link>
      <description>&lt;DIV&gt;Oui votre raisonnement est correct !&lt;/DIV&gt;&lt;DIV&gt;Objet 5 représente quel objet on étudie, et en fonction des différents objets les opérations et les numéros ont des correspondances différentes.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Je pense que ce code peut fonctionner :&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();&lt;BR /&gt;
dur_cols = Filter Each( {col_name}, dt &amp;lt;&amp;lt; Get Column Names( "String", Continuous ),
	Starts With( col_name, "durée" )
);

num_opé = Filter Each( {col_name}, dt &amp;lt;&amp;lt; Get Column Names( "String", Continuous ),
	Starts With( col_name, "opé" )
);

// for indexing later 
num_colnr = Transform Each( {col_name}, dur_cols, Word( -1, col_name ) );
// Add : Matrix of the index
num_colnr_mt = Matrix( Transform Each( {col_name}, dur_cols, Num( Word( -1, col_name ) ) ) )`;&lt;BR /&gt;
dt &amp;lt;&amp;lt; New Column( "DUREE",&lt;BR /&gt;Numeric,&lt;BR /&gt;Continuous,&lt;BR /&gt;Format( ":jou:hh:m", 8 ),&lt;BR /&gt;&amp;lt;&amp;lt;Set Each Value(&lt;BR /&gt;If( dt[Row(), num_opé ] &amp;lt; :"2100"n,&lt;BR /&gt;//colidx = Loc(dt[Row(), num_colnr] &amp;gt; :"opé"n &amp;amp; (num_colnr &amp;lt; 2100 ) );&lt;BR /&gt;colidx = Loc( dt[Row(), num_colnr] &amp;gt;= :"opé"n &amp;amp; (dt[Row(), num_colnr] &amp;lt; :"2100"n) ); // Changed&lt;BR /&gt;If( N Items( colidx ) &amp;gt; 0,&lt;BR /&gt;val = Sum( dt[Row(), dur_cols[colidx]] );&lt;BR /&gt;If( Is Missing( val ),&lt;BR /&gt;0,&lt;BR /&gt;val&lt;BR /&gt;);&lt;BR /&gt;,&lt;BR /&gt;0&lt;BR /&gt;);&lt;BR /&gt;,&lt;BR /&gt;0&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 25 May 2023 11:09:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calcul/m-p/635286#M83346</guid>
      <dc:creator>hcarr01</dc:creator>
      <dc:date>2023-05-25T11:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calcul</title>
      <link>https://community.jmp.com/t5/Discussions/Calcul/m-p/635348#M83351</link>
      <description>&lt;P&gt;I'm glad you were able to solve the problem yourself.&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 08:33:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calcul/m-p/635348#M83351</guid>
      <dc:creator>yuichi_katsumur</dc:creator>
      <dc:date>2023-05-25T08:33:07Z</dc:date>
    </item>
  </channel>
</rss>

