<?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: Counting objects over time with startDate &amp;amp; endDate in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4152561#M165037</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I understand your problem correctly, you want to count the number of ongoing statuses between a given start date and end date.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;For status XXX, one started on 1st Jan 2024 and ended on 29th Feb 2024, and another started on 1st Jan 2024 and ended on 31st March 2024.&lt;/P&gt;&lt;P&gt;In January, the count should be 2 since both started in this month.&lt;/P&gt;&lt;P&gt;In February, the count should still be 2 because the first one ends in February, and the second one, which ends in March, is still ongoing.&lt;/P&gt;&lt;P&gt;In March, the count would be 1 as only the second status is ongoing.&lt;/P&gt;&lt;P&gt;For status BBB, starting in January 2024 and ending in April, the count for February, March, and April will be 1 each month, as it continues through all those months.&lt;/P&gt;&lt;P&gt;The same logic applies to weekly calculations.&lt;/P&gt;&lt;P&gt;If this understanding is correct, here’s my suggested solution:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Prepare your data&lt;STRONG&gt;:&lt;/STRONG&gt; Go to Power Query and generate a list of rows for each status between the start and end dates.&lt;/LI&gt;&lt;LI&gt;Create a Date table&lt;STRONG&gt;:&lt;/STRONG&gt; You can create this in either Power Query or using DAX.&lt;/LI&gt;&lt;LI&gt;Write a small DAX.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The complete solution is in the link below.&lt;/P&gt;&lt;P&gt;&lt;A href="https://we.tl/t-t7VUBbwner" target="_blank" rel="noopener"&gt;https://we.tl/t-t7VUBbwner&lt;/A&gt;&lt;/P&gt;&lt;P&gt;below screenshot&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While I could solve this using DAX, but I always follow Roche's Maxim rule "Data should be transformed as far upstream as possible, and as far downstream as necessary."&lt;/P&gt;&lt;P&gt;If you need a DAX-only solution, please allow me some time to provide it. I must mention that it’s not an easy task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;sanalytics&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If it is your solution then please like and accept it as solution&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2024 13:46:48 GMT</pubDate>
    <dc:creator>sanalytics</dc:creator>
    <dc:date>2024-09-16T13:46:48Z</dc:date>
    <item>
      <title>Counting objects over time with startDate &amp; endDate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4151949#M164997</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get some inspiration/help to create a DAX measure. For my report, I need to display the count of statusses over time, using a start and enddate. Ideally, this should be dynamic. So that it works with both days, weeks and months on the axes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what the data looks like (text and picture format):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;status&lt;/TD&gt;&lt;TD&gt;startDate&lt;/TD&gt;&lt;TD&gt;endDate&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;XXX&lt;/TD&gt;&lt;TD&gt;1-1-2024&lt;/TD&gt;&lt;TD&gt;29-2-2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;YYY&lt;/TD&gt;&lt;TD&gt;1-2-2024&lt;/TD&gt;&lt;TD&gt;15-2-2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;BBB&lt;/TD&gt;&lt;TD&gt;1-1-2024&lt;/TD&gt;&lt;TD&gt;30-4-2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;XXX&lt;/TD&gt;&lt;TD&gt;1-1-2024&lt;/TD&gt;&lt;TD&gt;31-3-2024&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is how it should be visualized (example with months, but should work with days &amp;amp; weeks too):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have difficulty with creating something like this, so it would be great if some of you could help out! If you have any idea, please provide the DAX!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 07:26:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4151949#M164997</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-16T07:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counting objects over time with startDate &amp; endDate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4152170#M165006</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,Create a Date table if you don't already have one. This table should include all the dates you want to analyze.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a measure to count the statuses over time&lt;/P&gt;
&lt;P&gt;Status Count = &lt;BR /&gt;VAR SelectedDate = MAX('Date'[Date])&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('YourTable'),&lt;BR /&gt;FILTER(&lt;BR /&gt;'YourTable',&lt;BR /&gt;'YourTable'[startDate] &amp;lt;= SelectedDate &amp;amp;&amp;amp;&lt;BR /&gt;'YourTable'[endDate] &amp;gt;= SelectedDate&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 09:48:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4152170#M165006</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2024-09-16T09:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Counting objects over time with startDate &amp; endDate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4152202#M165012</link>
      <description>&lt;P&gt;Unfortunately I can't get it to work. These are the results I get:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also wondered if I shouldn't do something with the relationship between the endDate and Date from my datetable? Right now I only have a relationship between startDate and Date:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I suppose the measure also needs to be adjusted when I create two relationships.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 10:00:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4152202#M165012</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-16T10:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Counting objects over time with startDate &amp; endDate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4152493#M165035</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can write a measure as follows:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CountStatusesOverTime =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;SelectedDate&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'DimDate '&lt;/SPAN&gt;&lt;SPAN&gt;[Dates]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;statusCount&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;COUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Tbl&lt;/SPAN&gt;&lt;SPAN&gt;[Status]&lt;/SPAN&gt;&lt;SPAN&gt;) , &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;((&lt;/SPAN&gt;&lt;SPAN&gt;Tbl&lt;/SPAN&gt;&lt;SPAN&gt;) , &lt;/SPAN&gt;&lt;SPAN&gt;Tbl&lt;/SPAN&gt;&lt;SPAN&gt;[StartDate]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;SelectedDate&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;Tbl&lt;/SPAN&gt;&lt;SPAN&gt;[EndDate]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt;= &lt;/SPAN&gt;&lt;SPAN&gt;SelectedDate&lt;/SPAN&gt;&lt;SPAN&gt;) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;statusCount&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;** you should not have relation between dimdate and tbl and use dates of DimDate in X-axis&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If this post helps, then I would appreciate a thumbs up&amp;nbsp;&amp;nbsp;and mark it as the solution&amp;nbsp;to help the other members find it more quickly.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Sep 2024 13:16:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4152493#M165035</guid>
      <dc:creator>Selva-Salimi</dc:creator>
      <dc:date>2024-09-16T13:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Counting objects over time with startDate &amp; endDate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4152561#M165037</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I understand your problem correctly, you want to count the number of ongoing statuses between a given start date and end date.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;For status XXX, one started on 1st Jan 2024 and ended on 29th Feb 2024, and another started on 1st Jan 2024 and ended on 31st March 2024.&lt;/P&gt;&lt;P&gt;In January, the count should be 2 since both started in this month.&lt;/P&gt;&lt;P&gt;In February, the count should still be 2 because the first one ends in February, and the second one, which ends in March, is still ongoing.&lt;/P&gt;&lt;P&gt;In March, the count would be 1 as only the second status is ongoing.&lt;/P&gt;&lt;P&gt;For status BBB, starting in January 2024 and ending in April, the count for February, March, and April will be 1 each month, as it continues through all those months.&lt;/P&gt;&lt;P&gt;The same logic applies to weekly calculations.&lt;/P&gt;&lt;P&gt;If this understanding is correct, here’s my suggested solution:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Prepare your data&lt;STRONG&gt;:&lt;/STRONG&gt; Go to Power Query and generate a list of rows for each status between the start and end dates.&lt;/LI&gt;&lt;LI&gt;Create a Date table&lt;STRONG&gt;:&lt;/STRONG&gt; You can create this in either Power Query or using DAX.&lt;/LI&gt;&lt;LI&gt;Write a small DAX.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The complete solution is in the link below.&lt;/P&gt;&lt;P&gt;&lt;A href="https://we.tl/t-t7VUBbwner" target="_blank" rel="noopener"&gt;https://we.tl/t-t7VUBbwner&lt;/A&gt;&lt;/P&gt;&lt;P&gt;below screenshot&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While I could solve this using DAX, but I always follow Roche's Maxim rule "Data should be transformed as far upstream as possible, and as far downstream as necessary."&lt;/P&gt;&lt;P&gt;If you need a DAX-only solution, please allow me some time to provide it. I must mention that it’s not an easy task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;sanalytics&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If it is your solution then please like and accept it as solution&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 13:46:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4152561#M165037</guid>
      <dc:creator>sanalytics</dc:creator>
      <dc:date>2024-09-16T13:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Counting objects over time with startDate &amp; endDate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4154014#M165091</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much&amp;nbsp;sanalytics、Selva-Salimi&amp;nbsp;and bhanu_gautam&amp;nbsp;for your prompt reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your question, here is the method I provided:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's some dummy data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"StatusTable"&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a Date Table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DateTable = 
ADDCOLUMNS (
    CALENDAR (MIN('StatusTable'[startDate]), MAX('StatusTable'[endDate])),
    "Year", YEAR([Date]),
    "Month", FORMAT([Date], "MMM"),
    "Week", WEEKNUM([Date]),
    "Day", DAY([Date])
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a mesure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;StatusCount = 
VAR max_d = MAX('DateTable'[Date])
var min_d = MIN('DateTable'[Date])
VAR CountStatuses = 
    CALCULATE (
        COUNTROWS('StatusTable'),
        FILTER (
            'StatusTable',
            'StatusTable'[startDate] &amp;lt;= max_d &amp;amp;&amp;amp;
            'StatusTable'[endDate] &amp;gt;= min_d
        )
    )
RETURN
IF(ISBLANK(CountStatuses), 0, CountStatuses)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a Line chart visual.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Nono Chen&lt;/P&gt;
&lt;P&gt;If this &lt;STRONG&gt;&lt;EM&gt;post&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;helps, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 07:43:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-objects-over-time-with-startDate-amp-endDate/m-p/4154014#M165091</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-17T07:43:32Z</dc:date>
    </item>
  </channel>
</rss>

