<?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: Définir une intervalle de date entre début de mois jusqu'au la date d'aujourd'hui JMP16 in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770420#M95150</link>
    <description>&lt;P&gt;I would guess the issue is with your For loop. Most likely it can be optimized and you won't even need to use a loop. If you already have the knowledge of the rows you can use for example&lt;LI-MESSAGE title="Data table subscripting" uid="21013" url="https://community.jmp.com/t5/Uncharted/Data-table-subscripting/m-p/21013#U21013" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;to get the values you want from the table. You could also most likely use Subset + Summary to perform the calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can provide a small example of your data (or mock up date) which can be used to demonstrate I can give more suggestions. Also if you can provide an example try to provide some information about the correct results.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jul 2024 16:01:51 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-07-05T16:01:51Z</dc:date>
    <item>
      <title>Définir une intervalle de date entre début de mois jusqu'au la date d'aujourd'hui JMP16</title>
      <link>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770380#M95146</link>
      <description>&lt;P&gt;Bonjour,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Je rencontre depuis ce matin un problème avec mon script sur JMP et j'ai besoin de votre aide svp.&lt;/P&gt;&lt;P&gt;J'ai essayé de définir deux fonctions pour avoir la date de début de mois et la date d'aujourd'hui :&lt;BR /&gt;&lt;CODE class=""&gt;axe1:get_day_of_month&lt;/CODE&gt;&lt;SPAN&gt; - Cette fonction prend une date en entrée et renvoie le jour du mois sous forme de nombre.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;axe1:get_dates&lt;/CODE&gt;&lt;SPAN&gt; - Cette fonction récupère la date de début du mois en cours et la date du jour.&lt;BR /&gt;&lt;BR /&gt;Puis une fonction pour calculer :&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;//nb_total_ict et nb_total_fct : permettent de compter le nombre total de tests effectués&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;//nb_nok_ict et nb_nok_fct : permettent de compter le nombre de nok parmi tous les tests&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Afin de calculer le pourcentage de NOK pour les ICT&amp;nbsp;et les FCT entre le début de mois et la date d'aujourd'hui.&lt;BR /&gt;vous trouvez ci-joint une copie de la partie de mon code.&lt;BR /&gt;&lt;BR /&gt;Je vous remercie par avance.&lt;BR /&gt;&lt;BR /&gt;Cordialement,&lt;BR /&gt;Yass&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Fonction pour obtenir le jour du mois
axe1:get_day_of_month = Function({date},
	day_of_month = Num(Format(date, "dd"));
	day_of_month
);

// Fonction pour récupérer les dates
axe1:get_dates = Function({},
    today_date = Format(Today(), "yyyy-mm-dd");
    day_of_month = axe1:get_day_of_month(Today());
    start_of_month = Format(Today() - (day_of_month - 1), "yyyy-mm-dd");
    {start_of_month, today_date}
);

// Fonction pour calculer les pourcentages de NOK
axe1:calculate_nok_percentages = Function({dt},
    {start_of_month, today_date} = axe1:get_dates();

    // Initialisation des variables
    nb_total_ict = 0;
    nb_total_fct = 0;
    nb_nok_ict = 0;
    nb_nok_fct = 0;

    // Récupération des lignes correspondant à la période spécifiée
    FileRows = dt &amp;lt;&amp;lt; Get Rows Where(
        Num(Char(:Date)) &amp;gt;= Num(start_of_month) &amp;amp; Num(Char(:Date)) &amp;lt;= Num(today_date) &amp;amp; Contains(:File Name, "GOLDEN") == 0
    );

    total_rows = N Items(FileRows);

    For(j = 1, j &amp;lt;= total_rows, j++,
        If(dt:ICT_FCT[FileRows[j]] == "ICT",
            nb_total_ict += dt:Nb_de_lignes[FileRows[j]];
            If(dt:Result[FileRows[j]] == "NOK",
                nb_nok_ict += dt:Nb_de_lignes[FileRows[j]]
            )
        );
        If(dt:ICT_FCT[FileRows[j]] == "FCT",
            nb_total_fct += dt:Nb_de_lignes[FileRows[j]];
            If(dt:Result[FileRows[j]] == "NOK",
                nb_nok_fct += dt:Nb_de_lignes[FileRows[j]]
            )
        );
    );

    // Calcul des pourcentages NOK
    percent_nok_ict = (nb_nok_ict / nb_total_ict) * 100;
    percent_nok_fct = (nb_nok_fct / nb_total_fct) * 100;

    // Affichage des résultats
    Window("Analyse des données") &amp;lt;&amp;lt; Append(
        V List Box(
            Outline Box("Résultat NOK",
                Border Box(
                    Text Box("Pourcentage de NOK ICT du " || start_of_month || " au " || today_date || " : " || Char(Round(percent_nok_ict, 2)) || "%"),
                    Text Box("Pourcentage de NOK FCT du " || start_of_month || " au " || today_date || " : " || Char(Round(percent_nok_fct, 2)) || "%")
                )
            )
        )
    );
);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 14:38:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770380#M95146</guid>
      <dc:creator>Yass</dc:creator>
      <dc:date>2024-07-05T14:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Définir une intervalle de date entre début de mois jusqu'au la date d'aujourd'hui JMP16</title>
      <link>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770402#M95147</link>
      <description>&lt;P&gt;What is the problem you are having (translation in the community might be incorrect as I couldn't really find the issue easily)? Most likely you want to use &lt;A href="https://help.jmp.com/help?keyword=JSL%20Date%20Difference&amp;amp;lang=en&amp;amp;os=win&amp;amp;source=application&amp;amp;version=18.0.0" target="_blank" rel="noopener"&gt;Date Difference()&lt;/A&gt; or &lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/date-and-time-functions.shtml?os=win&amp;amp;source=application#ww2538996" target="_blank" rel="noopener"&gt;Date Increment()&lt;/A&gt;. Use "month" as intervalname and "start" as alignment to get the first date of month. For example first date of this month&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Date Increment(Today(), "Month", 0, "start");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;JMP also has Month() to get the month of date and many more &lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/date-and-time-functions.shtml#" target="_blank" rel="noopener"&gt;datetime functions&lt;/A&gt; which you might find useful for this type of work&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1720190829149.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65893iBBB60E3216A886B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1720190829149.png" alt="jthi_0-1720190829149.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 14:48:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770402#M95147</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-05T14:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Définir une intervalle de date entre début de mois jusqu'au la date d'aujourd'hui JMP16</title>
      <link>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770417#M95149</link>
      <description>&lt;P&gt;I tried to define two functions to get the start date of the month and today's date in order to&amp;nbsp;calculate the percentage of NOK results in a table for ICT and FCT based on a date table (dt).&lt;BR /&gt;&lt;BR /&gt;i did use&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;CODE&gt;axe1:get_day_of_month&lt;/CODE&gt; - This function takes a date as input and returns the day of the month as a number.&lt;/LI&gt;&lt;LI&gt;&lt;CODE&gt;axe1:get_dates&lt;/CODE&gt; - This function gets the start date of the current month and today's date.&lt;/LI&gt;&lt;LI&gt;&lt;CODE&gt;axe1:calculate_nok_percentages&lt;/CODE&gt; - This function calculates the percentage of NOK results for ICT and FCT based on a date table (dt). It filters the data for rows where the file name does not contain "GOLDEN" and then calculates the percentage of NOK for ICT and FCT for the specified date range.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;but every time i get this error message :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;JMP Alert&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The symbol evaluation is too recursive (&amp;gt;250 levels),&lt;/SPAN&gt;&lt;SPAN&gt; on line 1 during access or evaluation of &amp;lt;&amp;lt; start_of_month,&lt;/SPAN&gt;&lt;SPAN&gt; start_of_month&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;on line 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A stack overflow has been detected.&lt;/SPAN&gt;&lt;SPAN&gt; The maximum number of call levels has been exceeded.&lt;/SPAN&gt;&lt;SPAN&gt; Execution terminated on line 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 15:00:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770417#M95149</guid>
      <dc:creator>Yass</dc:creator>
      <dc:date>2024-07-05T15:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Définir une intervalle de date entre début de mois jusqu'au la date d'aujourd'hui JMP16</title>
      <link>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770420#M95150</link>
      <description>&lt;P&gt;I would guess the issue is with your For loop. Most likely it can be optimized and you won't even need to use a loop. If you already have the knowledge of the rows you can use for example&lt;LI-MESSAGE title="Data table subscripting" uid="21013" url="https://community.jmp.com/t5/Uncharted/Data-table-subscripting/m-p/21013#U21013" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;to get the values you want from the table. You could also most likely use Subset + Summary to perform the calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can provide a small example of your data (or mock up date) which can be used to demonstrate I can give more suggestions. Also if you can provide an example try to provide some information about the correct results.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 16:01:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770420#M95150</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-05T16:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Définir une intervalle de date entre début de mois jusqu'au la date d'aujourd'hui JMP16</title>
      <link>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770470#M95160</link>
      <description>&lt;P&gt;two possibilities, 2nd seems likely.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;axe1:get_day_of_month = Function({date},
{ day_of_month },// 1: use local variables
	day_of_month = Num(Format(date, "dd"));
	day_of_month
);

// Fonction pour récupérer les dates
axe1:get_dates = Function({},
    today_date = Format(Today(), "yyyy-mm-dd");
    day_of_month = axe1:get_day_of_month(Today());
    start_of_month = Format(Today() - (day_of_month - 1), "yyyy-mm-dd");
   // 2: use evallist
  evallist(  {start_of_month, today_date} )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;1: day_of_month may be global and may be confused between the functions&lt;/P&gt;
&lt;P&gt;2: the list you return has the names of the variables, not the values, and they get stored into...themselves. I think that will be the recursion.&lt;/P&gt;
&lt;P&gt;(Nice looking code!)&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 15:35:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770470#M95160</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2024-07-06T15:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Définir une intervalle de date entre début de mois jusqu'au la date d'aujourd'hui JMP16</title>
      <link>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770650#M95196</link>
      <description>&lt;P&gt;I would like to thank you for your suggestions and help.&lt;BR /&gt;&lt;BR /&gt;I ended up modifying my get_dates function where i did get Today's date and start of month&amp;nbsp;date and using a different For loop because I found some errors in the original loop. However, your suggestions were very helpful&lt;BR /&gt;that is the get_dates function :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;axe1:get_dates = Function({},
    today_date = Format(Today(), "yyyy-mm-dd");
    start_of_month = Format(Date Increment(Today(), "Month", 0, "Start"), "yyyy-mm-dd");
    evallist({start_of_month, today_date});
);&lt;/PRE&gt;&lt;P&gt;Thanks again for everything !&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 13:59:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/D%C3%A9finir-une-intervalle-de-date-entre-d%C3%A9but-de-mois-jusqu-au-la/m-p/770650#M95196</guid>
      <dc:creator>Yass</dc:creator>
      <dc:date>2024-07-08T13:59:03Z</dc:date>
    </item>
  </channel>
</rss>

