<?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: How to filter work days of task based on date slicer in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161471#M113558</link>
    <description>&lt;P&gt;Selected date range. the dates i set in the slicer. Basicaly have to calculate workdays that overlap with slicer date range and the task start and end dates&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2023 16:50:33 GMT</pubDate>
    <dc:creator>PMnooBI</dc:creator>
    <dc:date>2023-03-29T16:50:33Z</dc:date>
    <item>
      <title>How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161080#M113534</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see I have a table visual with workdays of tasks. I would like to have another column that displays the work days within the date range set in the slicer. For example, the task on third row has 5 days worth of work since it starts on 29th and ends on 4th but the slicer is between 27th and 1st. Hence, I want another column displaying just 3 work days for that task as the work is being done on 29th 30th and 31st only. Please let me know how I can implement this even if a task ends or starts in between a set date range.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The workday column is calculated as the difference between the start and end dates excluding the weekends&lt;/P&gt;&lt;P&gt;The date slicer has the calendar table date column added to it. The table visual displays the values from another data table called Assignments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="14361" data-lia-user-login="MFelix" class="lia-mention lia-mention-user"&gt;MFelix&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="107764" data-lia-user-login="Arul" class="lia-mention lia-mention-user"&gt;Arul&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="362560" data-lia-user-login="Ahmedx" class="lia-mention lia-mention-user"&gt;Ahmedx&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 14:06:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161080#M113534</guid>
      <dc:creator>PMnooBI</dc:creator>
      <dc:date>2023-03-29T14:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161279#M113545</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="537820" data-lia-user-login="PMnooBI" class="lia-mention lia-mention-user"&gt;PMnooBI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you may try&lt;/P&gt;
&lt;P&gt;=&lt;/P&gt;
&lt;P&gt;NETWORKDAYS ( MIN ( 'Date'[Date] ), &lt;SPAN&gt;MAX ( 'Date'[Date] ), 2 )&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 15:10:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161279#M113545</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-29T15:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161388#M113553</link>
      <description>&lt;P&gt;That just returns the working days by excluding weekends. I need a function to calculate number of days of a task only within a date range.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 15:59:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161388#M113553</guid>
      <dc:creator>PMnooBI</dc:creator>
      <dc:date>2023-03-29T15:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161469#M113557</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="537820" data-lia-user-login="PMnooBI" class="lia-mention lia-mention-user"&gt;PMnooBI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which date range? The selected date range or the date range between start and finish dates?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 16:48:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161469#M113557</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-29T16:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161471#M113558</link>
      <description>&lt;P&gt;Selected date range. the dates i set in the slicer. Basicaly have to calculate workdays that overlap with slicer date range and the task start and end dates&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 16:50:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161471#M113558</guid>
      <dc:creator>PMnooBI</dc:creator>
      <dc:date>2023-03-29T16:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161517#M113561</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="537820" data-lia-user-login="PMnooBI" class="lia-mention lia-mention-user"&gt;PMnooBI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope something like&lt;/P&gt;
&lt;P&gt;=&lt;BR /&gt;COUNTROWS (&lt;BR /&gt;INTERSECT (&lt;BR /&gt;CALENDAR (&lt;BR /&gt;MAX ( 'Table'[AssignmentSartDate] ),&lt;BR /&gt;MAX ( 'Table'[AssignmentFinishDate] )&lt;BR /&gt;),&lt;BR /&gt;VALUES ( 'Date'[Date] )&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 17:15:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161517#M113561</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-29T17:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161520#M113562</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="537820" data-lia-user-login="PMnooBI" class="lia-mention lia-mention-user"&gt;PMnooBI&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can work around it:&lt;BR /&gt;CALCULATE(COUNT(DAYS), FILTER(DATES, SELECTEDVALUE(DATES(DATE)) &amp;gt;= MIN(DATE) &amp;amp;&amp;amp; SELECTEDVALUE(DATES(DATE)) &amp;lt;= MAX(DATE))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dax will be depend on that you are using a date table or not.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 17:18:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161520#M113562</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-29T17:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161569#M113565</link>
      <description>&lt;P&gt;&lt;img /&gt;Great! It does work but it counts the weekends as well. Can the formula be modififed to not include weekends? and also you can see the time is 12:00 a.m. for both slicer date ranges and I think that is why it counts the next day as another one&lt;/P&gt;&lt;P&gt;"Task Days" is the output&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 17:57:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161569#M113565</guid>
      <dc:creator>PMnooBI</dc:creator>
      <dc:date>2023-03-29T17:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161596#M113566</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="537820" data-lia-user-login="PMnooBI" class="lia-mention lia-mention-user"&gt;PMnooBI&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the following code:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;days_ = 
var maxselecteddate = MAX(Calendar[Date])
var minselecteddate = MIN(Calendar[Date])
var startdatevalue = MAX( minselecteddate , SELECTEDVALUE('Table'[AssigmentStartDate]))
var enddatevalue = MIN( mAXselecteddate , SELECTEDVALUE('Table'[AssignementFinishDate]))
Return
NETWORKDAYS( startdatevalue, enddatevalue)
 &lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then make some adjustements to not get the negative values something similar to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;days_ = 
var maxselecteddate = MAX(Calendar[Date])
var minselecteddate = MIN(Calendar[Date])
var startdatevalue = MAX( minselecteddate , SELECTEDVALUE('Table'[AssigmentStartDate]))
var enddatevalue = MIN( mAXselecteddate , SELECTEDVALUE('Table'[AssignementFinishDate]))
var days_total = NETWORKDAYS( startdatevalue, enddatevalue)
Return
IF(days_total &amp;gt; 0 , days_total)&lt;/LI-CODE&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>Wed, 29 Mar 2023 18:05:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161596#M113566</guid>
      <dc:creator>MFelix</dc:creator>
      <dc:date>2023-03-29T18:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161731#M113578</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks! It did work but now for some reason the values won't add up and give me a total in the table visual shown in the image.&lt;/P&gt;&lt;P&gt;RESTCAP = Workperday*days_&lt;/P&gt;&lt;P&gt;My final goal is to find the total of these three columns. I was getting the sum with&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; 's solution but not with this.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 20:27:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3161731#M113578</guid>
      <dc:creator>PMnooBI</dc:creator>
      <dc:date>2023-03-29T20:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3162414#M113601</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="537820" data-lia-user-login="PMnooBI" class="lia-mention lia-mention-user"&gt;PMnooBI&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Yes, the weekends can be filtered out using&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;=
COUNTROWS (
    FILTER (
        INTERSECT (
            CALENDAR (
                MAX ( 'Table'[AssignmentSartDate] ),
                MAX ( 'Table'[AssignmentFinishDate] )
            ),
            VALUES ( 'Date'[Date] )
        ),
        NOT ( WEEKDAY ( [Date], 2 ) IN { 6, 7 } )
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;12:00AM is just a different format of 00:00 so I'm not sure if I fully understand what exactly the problem is.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 04:47:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3162414#M113601</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-30T04:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter work days of task based on date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3162858#M113644</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="537820" data-lia-user-login="PMnooBI" class="lia-mention lia-mention-user"&gt;PMnooBI&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the following code:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;days_ =
VAR maxselecteddate =
    MAX ( Calendar[Date] )
VAR minselecteddate =
    MIN ( Calendar[Date] )
VAR startdatevalue =
    MAX ( minselecteddate, MIN ( 'Table (2)'[AssignementStartDate] ) )
VAR enddatevalue =
    MIN ( mAXselecteddate, MIN ( 'Table (2)'[AssignementFinishDate] ) )
VAR days_total =
    NETWORKDAYS ( startdatevalue, enddatevalue )
VAR TableValues =
    ADDCOLUMNS (
        'Table (2)',
        "DaysTotal",
            VAR net_days =
                NETWORKDAYS (
                    MAX ( minselecteddate, 'Table (2)'[AssignementStartDate] ),
                    MIN ( mAXselecteddate, 'Table (2)'[AssignementFinishDate] )
                )
            RETURN
                IF ( net_days &amp;gt; 0, net_days )
    )
RETURN
    SUMX ( TableValues, [DaysTotal] )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 08:31:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-work-days-of-task-based-on-date-slicer/m-p/3162858#M113644</guid>
      <dc:creator>MFelix</dc:creator>
      <dc:date>2023-03-30T08:31:47Z</dc:date>
    </item>
  </channel>
</rss>

