<?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: Create measure counting number of available resources at any given time in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2792147#M87657</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="310729" data-lia-user-login="rubentj" class="lia-mention lia-mention-user"&gt;rubentj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't test to be honest, but please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Mumber of Days =
VAR MinDate =
    MIN ( 'Date'[Date] )
VAR MaxDate =
    MAX ( 'Date'[Date] )
VAR Dates1 =
    CALENDAR ( MinDate, MaxDate )
VAR Cars =
    CALCULATETABLE (
        'Cars Data',
        CROSSFILTER ( 'Cars Data'[StartDate], 'Date'[Date], NONE )
    ) -- in case no relationship just use 'Cars Data'
RETURN
    SUMX (
        Cars,
        VAR Dates2 =
            CALENDAR ( 'Cars Data'[StartDate], 'Cars Data'[EndtDate] )
        RETURN
            COUNTROWS ( INTERSECT ( Dates1, Dates2 ) )
    )&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 24 Sep 2022 19:13:39 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2022-09-24T19:13:39Z</dc:date>
    <item>
      <title>Create measure counting number of available resources at any given time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2792069#M87653</link>
      <description>&lt;P&gt;Hi guys.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;So, I have a table with information of cars location of any given time, where car movements are gives me a new row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CarId&lt;/TD&gt;&lt;TD&gt;Location&lt;/TD&gt;&lt;TD&gt;StartDate&lt;/TD&gt;&lt;TD&gt;EndDate&lt;/TD&gt;&lt;TD&gt;No. of days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;A&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;1/1/2020&lt;/TD&gt;&lt;TD&gt;1/20/2020&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;1/20/2020&lt;/TD&gt;&lt;TD&gt;1/25/2020&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;1/25/2020&lt;/TD&gt;&lt;TD&gt;12/31/2020&lt;/TD&gt;&lt;TD&gt;340&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;10/15/2020&lt;/TD&gt;&lt;TD&gt;11/30/2020&lt;/TD&gt;&lt;TD&gt;46&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;11/30/2020&lt;/TD&gt;&lt;TD&gt;12/31/2020&lt;/TD&gt;&lt;TD&gt;32&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to calculate is the number of "Car days" available in various periods (per day, per month, per quarter etc). For example, I want the measure to say that at 1/1/2020 there were 1 Car day (since only Car 1 was available on Location A - Car 2 didnt "exist" at that point in time). Further, in January 2020 on Location A, there were 20 (row A) + 6 (row 3 - this location data is calculated by StartDate being 1/25/2020 but end of month is 1/31/2020) = 26 available car days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, the issue I have is creating the logic where based on Min and Max dates i sum the number of days for each row, given the period I look at. If I evaluate per month basis, the Min(Date) is the 1st of the month and the Max(date) is the last day of the month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do of course have a standard Date table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ruben&lt;/P&gt;</description>
      <pubDate>Sat, 24 Sep 2022 18:40:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2792069#M87653</guid>
      <dc:creator>rubentj</dc:creator>
      <dc:date>2022-09-24T18:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create measure counting number of available resources at any given time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2792147#M87657</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="310729" data-lia-user-login="rubentj" class="lia-mention lia-mention-user"&gt;rubentj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't test to be honest, but please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Mumber of Days =
VAR MinDate =
    MIN ( 'Date'[Date] )
VAR MaxDate =
    MAX ( 'Date'[Date] )
VAR Dates1 =
    CALENDAR ( MinDate, MaxDate )
VAR Cars =
    CALCULATETABLE (
        'Cars Data',
        CROSSFILTER ( 'Cars Data'[StartDate], 'Date'[Date], NONE )
    ) -- in case no relationship just use 'Cars Data'
RETURN
    SUMX (
        Cars,
        VAR Dates2 =
            CALENDAR ( 'Cars Data'[StartDate], 'Cars Data'[EndtDate] )
        RETURN
            COUNTROWS ( INTERSECT ( Dates1, Dates2 ) )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 24 Sep 2022 19:13:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2792147#M87657</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-09-24T19:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create measure counting number of available resources at any given time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2792251#M87662</link>
      <description>&lt;P&gt;Thank you so much, this is art!!! - it looks very good, and at a first glance, it seems to work. Will do some reconsiliation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Sep 2022 20:04:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2792251#M87662</guid>
      <dc:creator>rubentj</dc:creator>
      <dc:date>2022-09-24T20:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create measure counting number of available resources at any given time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2819389#M89491</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="310729" data-lia-user-login="rubentj" class="lia-mention lia-mention-user"&gt;rubentj&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the above reply help?&lt;/P&gt;
&lt;P&gt;If the problem is resolved, please mark the reply as solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jay&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 09:55:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2819389#M89491</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-05T09:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create measure counting number of available resources at any given time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2864695#M92294</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the solution worked as per my requirement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I have come up with another thing I need to adjust for.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I count the car two times on the dates which have start and end dates. More specifically, if a Car has end date 31 Dec 2020, another entry has the start date 31 Dec 2020, meaning that I am double counting the cars.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried doing an easy fix to this by setting the end date to the date before, but this gives me the problem of the end date being previous to the start date, and this gives me an error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 11:37:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2864695#M92294</guid>
      <dc:creator>rubentj</dc:creator>
      <dc:date>2022-10-26T11:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create measure counting number of available resources at any given time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2865533#M92336</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="310729" data-lia-user-login="rubentj" class="lia-mention lia-mention-user"&gt;rubentj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;have you tried to minus one from EndDate?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Mumber of Days =
VAR MinDate =
    MIN ( 'Date'[Date] )
VAR MaxDate =
    MAX ( 'Date'[Date] )
VAR Dates1 =
    CALENDAR ( MinDate, MaxDate )
VAR Cars =
    CALCULATETABLE (
        'Cars Data',
        CROSSFILTER ( 'Cars Data'[StartDate], 'Date'[Date], NONE )
    ) -- in case no relationship just use 'Cars Data'
RETURN
    SUMX (
        Cars,
        VAR Dates2 =
            CALENDAR ( 'Cars Data'[StartDate], 'Cars Data'[EndtDate] - 1 )
        RETURN
            COUNTROWS ( INTERSECT ( Dates1, Dates2 ) )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 16:32:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2865533#M92336</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-26T16:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create measure counting number of available resources at any given time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2865594#M92339</link>
      <description>&lt;P&gt;Yes, but the problem is that in some cases, the start and end date is at the same date, but different time stamps. That gives me an error in the calendar function. Is it possible to exclude those cases from the calculation?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In addition, I have a timestamp in a column - is it possible to say that "if the start time stamp is after 12:00AM, use the following date" &amp;amp;&amp;amp; "if end date is before 12:00AM, use the previous date"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your help&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 17:02:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2865594#M92339</guid>
      <dc:creator>rubentj</dc:creator>
      <dc:date>2022-10-26T17:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create measure counting number of available resources at any given time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2865611#M92340</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="310729" data-lia-user-login="rubentj" class="lia-mention lia-mention-user"&gt;rubentj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;VAR Mumber of Days =
VAR MinDate =
    MIN ( 'Date'[Date] )
VAR MaxDate =
    MAX ( 'Date'[Date] )
VAR Dates1 =
    CALENDAR ( MinDate, MaxDate )
VAR Cars =
    CALCULATETABLE (
        'Cars Data',
        CROSSFILTER ( 'Cars Data'[StartDate], 'Date'[Date], NONE )
    ) -- in case no relationship just use 'Cars Data'
RETURN
    SUMX (
        Cars,
        VAR Dates2 =
            CALENDAR (
                'Cars Data'[StartDate],
                MAX ( 'Cars Data'[StartDate], 'Cars Data'[EndtDate] - 1 )
            )
        RETURN
            COUNTROWS ( INTERSECT ( Dates1, Dates2 ) )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 26 Oct 2022 17:09:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-measure-counting-number-of-available-resources-at-any/m-p/2865611#M92340</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-26T17:09:15Z</dc:date>
    </item>
  </channel>
</rss>

