<?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 Calculate Number of Units Per Month Based on Start and End Dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Number-of-Units-Per-Month-Based-on-Start-and-End-Dates/m-p/4150676#M164912</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Use case: Count the number of cars available per month based on a start and end dates.&lt;BR /&gt;Model: The model is simple one calendar and another fact table without relationship.&lt;BR /&gt;&lt;BR /&gt;Dax Formulas: I have achive this with 2 formulas, &lt;STRONG&gt;one is correct but with bad performance&lt;/STRONG&gt; another &lt;STRONG&gt;total is not correct for totals but the performance is good:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Pbix File:&amp;nbsp;&lt;A href="https://www.dropbox.com/scl/fi/jg34dgr9q48y0xbmqb599/NumberOfCars_PerYearMonthAndDay.pbix?rlkey=v0qrf65ooc3vmly6xg84kgota&amp;amp;st=a7oceioj&amp;amp;dl=0" target="_self"&gt;File with Example&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;Could you support me to achive the correct value with good performance.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Sep 2024 14:00:29 GMT</pubDate>
    <dc:creator>jmarciogsousa</dc:creator>
    <dc:date>2024-09-14T14:00:29Z</dc:date>
    <item>
      <title>Calculate Number of Units Per Month Based on Start and End Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Number-of-Units-Per-Month-Based-on-Start-and-End-Dates/m-p/4150676#M164912</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Use case: Count the number of cars available per month based on a start and end dates.&lt;BR /&gt;Model: The model is simple one calendar and another fact table without relationship.&lt;BR /&gt;&lt;BR /&gt;Dax Formulas: I have achive this with 2 formulas, &lt;STRONG&gt;one is correct but with bad performance&lt;/STRONG&gt; another &lt;STRONG&gt;total is not correct for totals but the performance is good:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Pbix File:&amp;nbsp;&lt;A href="https://www.dropbox.com/scl/fi/jg34dgr9q48y0xbmqb599/NumberOfCars_PerYearMonthAndDay.pbix?rlkey=v0qrf65ooc3vmly6xg84kgota&amp;amp;st=a7oceioj&amp;amp;dl=0" target="_self"&gt;File with Example&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;Could you support me to achive the correct value with good performance.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2024 14:00:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Number-of-Units-Per-Month-Based-on-Start-and-End-Dates/m-p/4150676#M164912</guid>
      <dc:creator>jmarciogsousa</dc:creator>
      <dc:date>2024-09-14T14:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Number of Units Per Month Based on Start and End Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Number-of-Units-Per-Month-Based-on-Start-and-End-Dates/m-p/4150775#M164920</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="694623" data-lia-user-login="jmarciogsousa" class="lia-mention lia-mention-user"&gt;jmarciogsousa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;_Cars_PerMonthAndDay = 
Var __Result =  SUMX(
                    'Calendar', 
                    Var __Date = 'Calendar'[Date]
                   return  COUNTROWS(
                        FILTER(
                            Cars, 
                            Cars[ValidFrom] &amp;lt;= __Date &amp;amp;&amp;amp;
                            Cars[ValidUntil] &amp;gt;= __Date
                        )
                   )
)
RETURN __Result  &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my observation, the results are accurate and it is performing better than your version.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need a Power BI Consultation? Hire me on &lt;A href="https://bit.ly/4d3oy4s" target="_blank" rel="noopener"&gt;Upwork&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Connect on &lt;A href="https://www.linkedin.com/in/tharun-kumar-ravikrindhi/" target="_blank" rel="noopener"&gt;LinkedIn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=""&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;DIV class=""&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;DIV style="border-radius: 1px; padding: 10px; border: solid #cccccc 1px; background: #fafafa no-repeat right 10px center;"&gt;&lt;BR /&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG style="margin-right: 3px;"&gt;&lt;STRONG style="margin-right: 3px;"&gt;Did I answer your question? Mark my post as a solution!&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG style="margin-right: 3px;"&gt;&lt;STRONG style="margin-right: 3px;"&gt;If I helped you, click on the Thumbs Up to give Kudos.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;BR /&gt;
&lt;P style="padding: 0; margin: 5px 50px 0 0;"&gt;Proud to be a Super User!&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;img /&gt;&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 14 Sep 2024 14:01:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Number-of-Units-Per-Month-Based-on-Start-and-End-Dates/m-p/4150775#M164920</guid>
      <dc:creator>tharunkumarRTK</dc:creator>
      <dc:date>2024-09-14T14:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Number of Units Per Month Based on Start and End Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Number-of-Units-Per-Month-Based-on-Start-and-End-Dates/m-p/4150917#M164938</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;_Cars_PerMonthAndDay = 
SUMX(
    Cars,
    VAR __from = Cars[ValidFrom]
    VAR __until = Cars[ValidUntil]
    RETURN
        CALCULATE(
            COUNTROWS( 'Calendar' ),
            'Calendar'[Date] &amp;gt;= __from,
            'Calendar'[Date] &amp;lt;= __until
        )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2024 19:51:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Number-of-Units-Per-Month-Based-on-Start-and-End-Dates/m-p/4150917#M164938</guid>
      <dc:creator>ThxAlot</dc:creator>
      <dc:date>2024-09-14T19:51:49Z</dc:date>
    </item>
  </channel>
</rss>

