<?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 Count of Items in Progress Using Dates in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Count-of-Items-in-Progress-Using-Dates/m-p/637482#M83524</link>
    <description>&lt;P&gt;Hello, I made this example data set to show the issue I am working through:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table("Project Status",
	Add Rows(5),
	New Column("Project", Character, "Nominal", Formula("Project " || Char(Row()))),
	New Column("Start Date", Numeric, "Ordinal", Format("m/d/y", 12), Formula(Date Increment( Today() - In Days( Row() * 10 ), "Day" ))),
	New Column("End Date", Numeric, "Ordinal", Format("m/d/y", 12), Formula(Date Increment( Today() + In Days( Row() * 10 ), "Day" )))
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The following code will create a 5x3 Data Table with beginning and end dates for 5 different projects. What I would like to do is get a count of "projects in progress" for all month/year combos in the data set. By that I mean any project that's beginning date should be counted for that month until the end date has passed. Here is an image example of what I am hoping to produce:&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="PIP.png" style="width: 181px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/53295i0C435A4CFE068B85/image-size/large?v=v2&amp;amp;px=999" role="button" title="PIP.png" alt="PIP.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there a way to get these counts into their own data table using JSL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if I can provide any more info on what I am trying to accomplish.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jun 2023 00:01:50 GMT</pubDate>
    <dc:creator>DerekMoore</dc:creator>
    <dc:date>2023-06-11T00:01:50Z</dc:date>
    <item>
      <title>Count of Items in Progress Using Dates</title>
      <link>https://community.jmp.com/t5/Discussions/Count-of-Items-in-Progress-Using-Dates/m-p/637482#M83524</link>
      <description>&lt;P&gt;Hello, I made this example data set to show the issue I am working through:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table("Project Status",
	Add Rows(5),
	New Column("Project", Character, "Nominal", Formula("Project " || Char(Row()))),
	New Column("Start Date", Numeric, "Ordinal", Format("m/d/y", 12), Formula(Date Increment( Today() - In Days( Row() * 10 ), "Day" ))),
	New Column("End Date", Numeric, "Ordinal", Format("m/d/y", 12), Formula(Date Increment( Today() + In Days( Row() * 10 ), "Day" )))
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The following code will create a 5x3 Data Table with beginning and end dates for 5 different projects. What I would like to do is get a count of "projects in progress" for all month/year combos in the data set. By that I mean any project that's beginning date should be counted for that month until the end date has passed. Here is an image example of what I am hoping to produce:&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="PIP.png" style="width: 181px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/53295i0C435A4CFE068B85/image-size/large?v=v2&amp;amp;px=999" role="button" title="PIP.png" alt="PIP.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there a way to get these counts into their own data table using JSL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if I can provide any more info on what I am trying to accomplish.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 00:01:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-of-Items-in-Progress-Using-Dates/m-p/637482#M83524</guid>
      <dc:creator>DerekMoore</dc:creator>
      <dc:date>2023-06-11T00:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Count of Items in Progress Using Dates</title>
      <link>https://community.jmp.com/t5/Discussions/Count-of-Items-in-Progress-Using-Dates/m-p/637509#M83526</link>
      <description>&lt;P&gt;I would maybe write this as SQL query, but it can be also done in JSL. Below is one possible option (there are many simpler and more complicate ones)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Project Status",
	Add Rows(5),
	New Column("Project", Character, "Nominal", Formula("Project " || Char(Row()))),
	New Column("Start Date", Numeric, "Ordinal", Format("m/d/y", 12), Formula(Date Increment(Today() - In Days(Row() * 10), "Day"))),
	New Column("End Date", Numeric, "Ordinal", Format("m/d/y", 12), Formula(Date Increment(Today() + In Days(Row() * 10), "Day")))
);
dt &amp;lt;&amp;lt; Run Formulas;
:Start Date &amp;lt;&amp;lt; Delete Formula;
:End Date &amp;lt;&amp;lt; Delete Formula;

// Add monthyear column based on Start Date
new_col1 = dt &amp;lt;&amp;lt; New Column("MonthYear1",
	Numeric,
	"Ordinal",
	Format("m/y", 12),
	Formula(Date DMY(1, Month(:Start Date), Year(:Start Date)))
);

new_col2 = dt &amp;lt;&amp;lt; New Column("MonthYear2",
	Numeric,
	"Ordinal",
	Format("m/y", 12),
	Formula(Date DMY(1, Month(:End Date), Year(:Start Date)))
);

// calculation should be based on min date and max date found from dataset in my opinion
// not based on the found values, but this is easier so I'll use this
date_months = Associative Array(new_col1);
date_months &amp;lt;&amp;lt; Insert(Associative Array(new_col2));
dt &amp;lt;&amp;lt; Delete Columns({"MonthYear1", "MonthYear2"});

aa_results = Associative Array();

For Each({month_start}, date_months &amp;lt;&amp;lt; get keys,
	// last day of month
	max_day = In Days(Days In Month(Year(month_start), Month(month_start))) + month_start - Time Of Day(month_start);
	// some logic to get projects
	r = dt &amp;lt;&amp;lt; Get Rows Where((:Start Date &amp;lt;= month_start &amp;amp; :End Date &amp;gt;= month_start) | (month_start &amp;lt;= :Start Date &amp;lt; max_day));
	aa_results[month_start] = N Items(r);
);

dt_results = New Table("Results",
	New Column("MY", Numeric, Continuous, Values(aa_results &amp;lt;&amp;lt; get keys)),
	New Column("ProjInProg", Numeric, Continuous, Values(aa_results &amp;lt;&amp;lt; get values)),
);&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-1685555362466.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/53301iC97A7DA9B5D80DAC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1685555362466.png" alt="jthi_0-1685555362466.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 17:49:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-of-Items-in-Progress-Using-Dates/m-p/637509#M83526</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-05-31T17:49:34Z</dc:date>
    </item>
  </channel>
</rss>

