<?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: Sum if value is between two dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933684#M96580</link>
    <description>&lt;P&gt;hi&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;See Hours table.&lt;/P&gt;&lt;P&gt;Employee ID 2 has Schedule ID 1, which is in the Hours table 5 times 8hours.&lt;/P&gt;&lt;P&gt;Employee ID 59 has Schedule ID 35, 51 and 70, which is in the Hours table 3 times 8 hours.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 18:25:20 GMT</pubDate>
    <dc:creator>JC2022</dc:creator>
    <dc:date>2022-11-28T18:25:20Z</dc:date>
    <item>
      <title>Sum if value is between two dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933421#M96564</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to calculate the hours for each employee on each day (and sum these per period).&lt;/P&gt;&lt;P&gt;First I need to check the Schedule ID per Employee ID on each day, because this can change over time (as you can see below in Schedule table for Employee ID 59).&lt;/P&gt;&lt;P&gt;Then I need to calculate the correct hours belonging to the correct Schedule ID on a particular date for each Employee ID. This probably by checking if the date in my Hours table is between from date and to date in my Schedule table.&lt;/P&gt;&lt;P&gt;I would like to do this in a measure where the result for Employee ID 2 should be 5*8hours=40hours. And the result for Employee ID 59 should be 3*8hours=24hours. By filtering on the Date table the results should be recalculated as a measure does.&lt;/P&gt;&lt;P&gt;Can anyone help me with this measure formula?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 3 tables as below:&lt;/P&gt;&lt;P&gt;Schedule table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hours table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date table (calendar table, with every date):&lt;/P&gt;&lt;P&gt;&lt;img /&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;</description>
      <pubDate>Mon, 28 Nov 2022 15:53:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933421#M96564</guid>
      <dc:creator>JC2022</dc:creator>
      <dc:date>2022-11-28T15:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sum if value is between two dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933454#M96566</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="478342" data-lia-user-login="JC2022" class="lia-mention lia-mention-user"&gt;JC2022&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where did the 5 and the 3 come from? Any relationships between the tables?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 16:00:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933454#M96566</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-11-28T16:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sum if value is between two dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933684#M96580</link>
      <description>&lt;P&gt;hi&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;See Hours table.&lt;/P&gt;&lt;P&gt;Employee ID 2 has Schedule ID 1, which is in the Hours table 5 times 8hours.&lt;/P&gt;&lt;P&gt;Employee ID 59 has Schedule ID 35, 51 and 70, which is in the Hours table 3 times 8 hours.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 18:25:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933684#M96580</guid>
      <dc:creator>JC2022</dc:creator>
      <dc:date>2022-11-28T18:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sum if value is between two dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933706#M96586</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="478342" data-lia-user-login="JC2022" class="lia-mention lia-mention-user"&gt;JC2022&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;=
SUMX (
    Schedule,
    SUMX (
        FILTER (
            Hours,
            Hours[Schedule ID] = Schedule[Schedule ID]
                &amp;amp;&amp;amp; Hours[Date] &amp;gt;= Schedule[From Date]
                &amp;amp;&amp;amp; Hours[Date] &amp;lt;= Schedule[To Date]
        ),
        Schedule[Hours]
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 28 Nov 2022 18:44:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933706#M96586</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-11-28T18:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sum if value is between two dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933789#M96593</link>
      <description>&lt;P&gt;&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;&lt;P&gt;Thank you very much! It is working.&lt;/P&gt;&lt;P&gt;But I do have an additional question. When there is a Holiday table, with all the holiday days. How can I exclude these holiday dates from this formula?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 19:48:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933789#M96593</guid>
      <dc:creator>JC2022</dc:creator>
      <dc:date>2022-11-28T19:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sum if value is between two dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933871#M96600</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="478342" data-lia-user-login="JC2022" class="lia-mention lia-mention-user"&gt;JC2022&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;=&lt;BR /&gt;SUMX (&lt;BR /&gt;Schedule,&lt;BR /&gt;SUMX (&lt;BR /&gt;FILTER (&lt;BR /&gt;Hours,&lt;BR /&gt;VAR Dates =&lt;BR /&gt;CALENDAR ( Schedule[From Date], Schedule[To Date] )&lt;BR /&gt;VAR Dates2 =&lt;BR /&gt;EXCEPT ( Dates, VALUES ( Holidays[Date] ) )&lt;BR /&gt;RETURN&lt;BR /&gt;Hours[Schedule ID] = Schedule[Schedule ID]&lt;BR /&gt;&amp;amp;&amp;amp; Hours[Date] IN Dates2&lt;BR /&gt;),&lt;BR /&gt;Schedule[Hours]&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 20:32:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933871#M96600</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-11-28T20:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sum if value is between two dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933909#M96603</link>
      <description>&lt;P&gt;&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;&lt;P&gt;This is not working. The last mentioned table and column in your formula are Schedule[Hours], but my Schedule table does not have Hours as a column. I assume you are referring to my Hours table?&lt;/P&gt;&lt;P&gt;But even with this change it is not working. It is calculating for more than 10 minutes now (see my image below). Don't think this is correct.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after 15 minutes definite sign this is not working.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 21:01:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933909#M96603</guid>
      <dc:creator>JC2022</dc:creator>
      <dc:date>2022-11-28T21:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sum if value is between two dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933926#M96605</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="478342" data-lia-user-login="JC2022" class="lia-mention lia-mention-user"&gt;JC2022&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Indeed this is a very heavy calculation. It would work with a small set of data.&amp;nbsp;&lt;BR /&gt;Is the Schedule ID in the Schedule table unique? If so you can build a relationship between the two tables. This by itself would make the calculation much faster and further shall open the door for further optimization.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 21:15:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933926#M96605</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-11-28T21:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sum if value is between two dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933937#M96606</link>
      <description>&lt;P&gt;&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;&lt;P&gt;No this Schedule ID in the Schedule table is not unique, because multiple Employee ID can have the same Schedule ID. What is the best solution to get the requested result?&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;</description>
      <pubDate>Mon, 28 Nov 2022 21:21:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-if-value-is-between-two-dates/m-p/2933937#M96606</guid>
      <dc:creator>JC2022</dc:creator>
      <dc:date>2022-11-28T21:21:42Z</dc:date>
    </item>
  </channel>
</rss>

