<?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: DAX Query for working days in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-for-working-days/m-p/3703236#M144036</link>
    <description>&lt;P&gt;To calculate the total number of working days based on the user-selected date range and restrict the maximum working days for a month to 20 days in Power BI using DAX, you can follow these steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a measure that calculates the total working days using the NETWORKDAYS function.&lt;/LI&gt;&lt;LI&gt;Create another measure to restrict the maximum working days to 20 days per month.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here's how you can do it:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Calculate Total Working Days:&lt;/STRONG&gt; Create a measure named Total Working Days that calculates the total working days between the start date and end date selected by the user.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Total Working Days =&lt;BR /&gt;VAR StartDate = MIN('Date'[Date])&lt;BR /&gt;VAR EndDate = MAX('Date'[Date])&lt;BR /&gt;RETURN&lt;BR /&gt;NETWORKDAYS(StartDate, EndDate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Restrict Maximum Working Days to 20:&lt;/STRONG&gt;&lt;SPAN&gt; Create a measure named &lt;/SPAN&gt;Restricted Working Days&lt;SPAN&gt; that restricts the total working days to a maximum of 20 days per month.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Restricted Working Days =&lt;BR /&gt;VAR TotalDays = [Total Working Days]&lt;BR /&gt;VAR MaxDaysPerMonth = 20&lt;BR /&gt;VAR StartMonth = MONTH(MIN('Date'[Date]))&lt;BR /&gt;VAR EndMonth = MONTH(MAX('Date'[Date]))&lt;BR /&gt;VAR MonthsInRange = EndMonth - StartMonth + 1&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;TotalDays &amp;gt; MaxDaysPerMonth * MonthsInRange,&lt;BR /&gt;MaxDaysPerMonth * MonthsInRange,&lt;BR /&gt;TotalDays&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Display the Results:&lt;/STRONG&gt; Now, you can use the Restricted Working Days measure in your visualizations to display the desired result.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Ensure that you have a proper date table ('Date') that covers the entire range of dates in your dataset.&lt;/P&gt;&lt;P&gt;With these measures in place, you can now calculate the total working days based on the user-selected date range and restrict the maximum working days to 20 days per month, as per your requirements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Feb 2024 06:46:50 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2024-02-16T06:46:50Z</dc:date>
    <item>
      <title>DAX Query for working days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-for-working-days/m-p/3703231#M144035</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I have a date table as shown in the table below.&lt;/P&gt;&lt;P&gt;I want to calculate the total number of working days based on the date filtered by the user in visualization and restrict the maximum working days for a month to 20 days.&lt;/P&gt;&lt;P&gt;Below are a few examples of the results that I am looking for.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Example&lt;/TD&gt;&lt;TD&gt;Start date&lt;/TD&gt;&lt;TD&gt;End Date&lt;/TD&gt;&lt;TD&gt;Working days using "NETWROKDAYS DAX"&lt;/TD&gt;&lt;TD&gt;The result I am looking for&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;01-Jan-24&lt;/TD&gt;&lt;TD&gt;31-Jan-24&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;01-Jan-24&lt;/TD&gt;&lt;TD&gt;15-Jan-24&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;01-Jan-24&lt;/TD&gt;&lt;TD&gt;15-Feb-24&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;TD&gt;20+11=31&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;Date&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;01-Jan-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;02-Jan-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;03-Jan-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;04-Jan-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;05-Jan-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;06-Jan-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;25-Mar-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;26-Mar-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;27-Mar-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;28-Mar-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;29-Mar-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;30-Mar-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="2"&gt;31-Mar-24&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 06:42:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-for-working-days/m-p/3703231#M144035</guid>
      <dc:creator>prashantg364</dc:creator>
      <dc:date>2024-02-16T06:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Query for working days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-for-working-days/m-p/3703236#M144036</link>
      <description>&lt;P&gt;To calculate the total number of working days based on the user-selected date range and restrict the maximum working days for a month to 20 days in Power BI using DAX, you can follow these steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a measure that calculates the total working days using the NETWORKDAYS function.&lt;/LI&gt;&lt;LI&gt;Create another measure to restrict the maximum working days to 20 days per month.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here's how you can do it:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Calculate Total Working Days:&lt;/STRONG&gt; Create a measure named Total Working Days that calculates the total working days between the start date and end date selected by the user.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Total Working Days =&lt;BR /&gt;VAR StartDate = MIN('Date'[Date])&lt;BR /&gt;VAR EndDate = MAX('Date'[Date])&lt;BR /&gt;RETURN&lt;BR /&gt;NETWORKDAYS(StartDate, EndDate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Restrict Maximum Working Days to 20:&lt;/STRONG&gt;&lt;SPAN&gt; Create a measure named &lt;/SPAN&gt;Restricted Working Days&lt;SPAN&gt; that restricts the total working days to a maximum of 20 days per month.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Restricted Working Days =&lt;BR /&gt;VAR TotalDays = [Total Working Days]&lt;BR /&gt;VAR MaxDaysPerMonth = 20&lt;BR /&gt;VAR StartMonth = MONTH(MIN('Date'[Date]))&lt;BR /&gt;VAR EndMonth = MONTH(MAX('Date'[Date]))&lt;BR /&gt;VAR MonthsInRange = EndMonth - StartMonth + 1&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;TotalDays &amp;gt; MaxDaysPerMonth * MonthsInRange,&lt;BR /&gt;MaxDaysPerMonth * MonthsInRange,&lt;BR /&gt;TotalDays&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Display the Results:&lt;/STRONG&gt; Now, you can use the Restricted Working Days measure in your visualizations to display the desired result.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Ensure that you have a proper date table ('Date') that covers the entire range of dates in your dataset.&lt;/P&gt;&lt;P&gt;With these measures in place, you can now calculate the total working days based on the user-selected date range and restrict the maximum working days to 20 days per month, as per your requirements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 06:46:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-for-working-days/m-p/3703236#M144036</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-02-16T06:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Query for working days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-for-working-days/m-p/3703308#M144043</link>
      <description>&lt;P&gt;Thanks for the suggestion, but still the result is incorrect&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 07:24:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-for-working-days/m-p/3703308#M144043</guid>
      <dc:creator>prashantg364</dc:creator>
      <dc:date>2024-02-16T07:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Query for working days</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-for-working-days/m-p/3703468#M144053</link>
      <description>&lt;P&gt;Do you have the option of amending the source for the date table? I implemented this in MySQL using the following in the view -&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;NOT(
	WEEKDAY(dat.date) IN (5,6) OR hols.date IS NOT NULL
) AS 'Is Working Day',&lt;/LI-CODE&gt;&lt;P&gt;'hols' is just a table containing dates for any holidays the buiness will be shut for. This way you can then simply sum this field for any filtered range on your date table.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 08:46:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-for-working-days/m-p/3703468#M144053</guid>
      <dc:creator>philadams</dc:creator>
      <dc:date>2024-02-16T08:46:59Z</dc:date>
    </item>
  </channel>
</rss>

