<?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 Finding Working Hours Between Two Dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-Working-Hours-Between-Two-Dates/m-p/2711026#M82356</link>
    <description>&lt;P&gt;I'm trying to find the number of working hours between two dates. I have a start and end date. Right now, I'm finding the number of working days between the dates and then multiplying it by the hours in the work day, but this is resulting in some rounding error (i.e. 4.3 days is rounded to 4 days). Is there a way to get a fraction of a day or calculate the working hours outright?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working Hours -- 1st Shift is Monday to Friday 8 hours/day&lt;/P&gt;&lt;P&gt;2nd Shift is Monday to Thursday 10 hours/day -- only certain entries have a second shift&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now I'm finding the 1st shift working days and the 2nd shift working days separately and then adding them together.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some of the DAX used in calculated columns below for reference. Are there any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Find the number of first shift working days for an entry. It's the same for second shift but &amp;lt;=4&lt;/P&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;MyDates&lt;/SPAN&gt;&lt;SPAN&gt; =&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;GENERATESERIES&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Status Start Time]&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[Status End Time]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;"Day"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;WEEKDAY&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Value]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;) // 1= Monday and 7 = Sunday&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;COUNTROWS&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;MyDates&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[Day]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;)) &lt;/SPAN&gt;&lt;SPAN&gt;//&amp;lt;= 5 means the weekday is monday through friday&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;2. Add the 1st shift and 2nd shift days to find the total working hours&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;Past Month Hours Duration = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;'Historical Tech Center Submissions'[First Shift Days Past Month]&lt;/SPAN&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;8&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;SPAN&gt;'Historical Tech Center Submissions'[Second Shift Days Past Month]&lt;/SPAN&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;10&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 18 Aug 2022 22:09:45 GMT</pubDate>
    <dc:creator>hsparg008</dc:creator>
    <dc:date>2022-08-18T22:09:45Z</dc:date>
    <item>
      <title>Finding Working Hours Between Two Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-Working-Hours-Between-Two-Dates/m-p/2711026#M82356</link>
      <description>&lt;P&gt;I'm trying to find the number of working hours between two dates. I have a start and end date. Right now, I'm finding the number of working days between the dates and then multiplying it by the hours in the work day, but this is resulting in some rounding error (i.e. 4.3 days is rounded to 4 days). Is there a way to get a fraction of a day or calculate the working hours outright?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working Hours -- 1st Shift is Monday to Friday 8 hours/day&lt;/P&gt;&lt;P&gt;2nd Shift is Monday to Thursday 10 hours/day -- only certain entries have a second shift&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now I'm finding the 1st shift working days and the 2nd shift working days separately and then adding them together.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some of the DAX used in calculated columns below for reference. Are there any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Find the number of first shift working days for an entry. It's the same for second shift but &amp;lt;=4&lt;/P&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;MyDates&lt;/SPAN&gt;&lt;SPAN&gt; =&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;GENERATESERIES&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Status Start Time]&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[Status End Time]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;"Day"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;WEEKDAY&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Value]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;) // 1= Monday and 7 = Sunday&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;COUNTROWS&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;MyDates&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[Day]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;)) &lt;/SPAN&gt;&lt;SPAN&gt;//&amp;lt;= 5 means the weekday is monday through friday&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;2. Add the 1st shift and 2nd shift days to find the total working hours&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;Past Month Hours Duration = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;'Historical Tech Center Submissions'[First Shift Days Past Month]&lt;/SPAN&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;8&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;SPAN&gt;'Historical Tech Center Submissions'[Second Shift Days Past Month]&lt;/SPAN&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;10&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Aug 2022 22:09:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-Working-Hours-Between-Two-Dates/m-p/2711026#M82356</guid>
      <dc:creator>hsparg008</dc:creator>
      <dc:date>2022-08-18T22:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Working Hours Between Two Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-Working-Hours-Between-Two-Dates/m-p/2711121#M82370</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="400650" data-lia-user-login="hsparg008" class="lia-mention lia-mention-user"&gt;hsparg008&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you turn a date/time into a number (say, you multiply it by 1.0), it'll give you a number. On such numbers you can carry out arithmetic to obtain durations in (fractional) days. Check this out:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;EVALUATE
var dt = convert("2020-12-10 14:20:12", DATETIME)
return
    {(1.0 * dt, dt)}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run this in DAX Studio as is.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 23:43:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-Working-Hours-Between-Two-Dates/m-p/2711121#M82370</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-08-18T23:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Working Hours Between Two Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-Working-Hours-Between-Two-Dates/m-p/2719307#M82857</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="400650" data-lia-user-login="hsparg008" class="lia-mention lia-mention-user"&gt;hsparg008&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A new DAX used to return the number of workdays between date range. It always returns whole number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NETWORKDAYS(&amp;lt;start_date&amp;gt;, &amp;lt;end_date&amp;gt;[, &amp;lt;weekend&amp;gt;, &amp;lt;holidays&amp;gt;])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/EN-US/dax/networkdays-dax" target="_blank"&gt;NETWORKDAYS function (DAX) - DAX | Microsoft Docs&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ chenwu zhu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 07:50:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-Working-Hours-Between-Two-Dates/m-p/2719307#M82857</guid>
      <dc:creator>v-chenwuz-msft</dc:creator>
      <dc:date>2022-08-23T07:50:42Z</dc:date>
    </item>
  </channel>
</rss>

