<?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: Need to count the number rows between two date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-count-the-number-rows-between-two-date/m-p/3562943#M137338</link>
    <description>&lt;P&gt;I add the date field to the X-Axis and the measure to Y-axis to create the following chart.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Dec 2023 11:31:12 GMT</pubDate>
    <dc:creator>leekohr</dc:creator>
    <dc:date>2023-12-01T11:31:12Z</dc:date>
    <item>
      <title>Need to count the number rows between two date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-count-the-number-rows-between-two-date/m-p/3562325#M137305</link>
      <description>&lt;P&gt;I would like to build table that counts the number of records between to dates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have data below call Data and date table called Calendar. My Data table looks like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have date table has one column with all the dates from my data colunm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use the following measure, I return only the date that are equal to the start date. When there is a relationship between Data[Start Date] and Calendar'[Date].&amp;nbsp; We I remove the relationship it works as expected. My question is why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OpenItems =&lt;BR /&gt;VAR DateX = MAX('Calendar'[Date])&lt;BR /&gt;Return&lt;BR /&gt;CALCULATE(COUNTROWS(Data),Data[Start Date]&amp;lt;=DateX)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OpenItems =&lt;BR /&gt;VAR DateX = MAX('Calendar'[Date])&lt;BR /&gt;Return&lt;BR /&gt;CALCULATE(COUNTROWS(Data),Data[Start Date]&amp;lt;=DateX &amp;amp;&amp;amp; Data[End Date]&amp;gt;Datex)&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 03:55:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-count-the-number-rows-between-two-date/m-p/3562325#M137305</guid>
      <dc:creator>leekohr</dc:creator>
      <dc:date>2023-12-01T03:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need to count the number rows between two date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-count-the-number-rows-between-two-date/m-p/3562464#M137307</link>
      <description>&lt;P&gt;how is your measure visualized or what filter context do you have?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it could be that you are using the calendar[date] to get a date range and a date point in the same time, so only the the date point meets such requirement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 06:12:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-count-the-number-rows-between-two-date/m-p/3562464#M137307</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-12-01T06:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need to count the number rows between two date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-count-the-number-rows-between-two-date/m-p/3562943#M137338</link>
      <description>&lt;P&gt;I add the date field to the X-Axis and the measure to Y-axis to create the following chart.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 11:31:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-count-the-number-rows-between-two-date/m-p/3562943#M137338</guid>
      <dc:creator>leekohr</dc:creator>
      <dc:date>2023-12-01T11:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need to count the number rows between two date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-count-the-number-rows-between-two-date/m-p/3565610#M137456</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="122977" data-lia-user-login="leekohr" class="lia-mention lia-mention-user"&gt;leekohr&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The behavior you're observing is likely due to the way DAX handles filter context in Power BI. When there is an active relationship between the Data table and the Calendar table, the filter context is automatically applied based on that relationship. This means that when you calculate the measure, it is only considering the dates that match exactly in both tables due to the relationship.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here's a step-by-step action plan to resolve the issue: &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. Review Relationships:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- Ensure that the relationship between the Data table and the Calendar table is set up correctly. It should typically be a one-to-many relationship, with the Calendar table on the "one" side. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Modify the Measure:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; - You may need to adjust your measure to ignore the filter context imposed by the relationship. You can do this by using the &lt;A href="https://learn.microsoft.com/en-us/dax/all-function-dax" target="_blank" rel="noopener"&gt;ALL() function&lt;/A&gt; or to&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/removefilters-function-dax" target="_blank" rel="noopener"&gt;REMOVEFILTERS() function&lt;/A&gt;&amp;nbsp;&lt;SPAN&gt;the filter context from the Calendar table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;OpenItems = 
VAR DateX = MAX('Calendar'[Date])
Return
COUNTROWS(FILTER(ALL(Data),Data[Start Date]&amp;lt;=DateX &amp;amp;&amp;amp; Data[End Date]&amp;gt;Datex))&lt;/LI-CODE&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 07:48:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-count-the-number-rows-between-two-date/m-p/3565610#M137456</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-12-04T07:48:53Z</dc:date>
    </item>
  </channel>
</rss>

