<?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: Date table - Aligning workdays over months in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-table-Aligning-workdays-over-months/m-p/4297021#M170593</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="588595" data-lia-user-login="Jodallen123" class="lia-mention lia-mention-user"&gt;Jodallen123&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To create a &lt;STRONG&gt;workday-aligned date slicer&lt;/STRONG&gt; that works across months in Power BI, follow these steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Create a Date Table&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a &lt;STRONG&gt;Date Table&lt;/STRONG&gt; with all the dates needed, ensuring you have columns for &lt;STRONG&gt;Day of the Week&lt;/STRONG&gt;, &lt;STRONG&gt;Month&lt;/STRONG&gt;, &lt;STRONG&gt;Year&lt;/STRONG&gt;, and &lt;STRONG&gt;Workday Flag&lt;/STRONG&gt; (to indicate whether it's a workday or not).&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Add Workday Column&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Add a column to calculate whether a date is a workday (e.g., weekdays but excluding holidays).&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;WorkdayFlag = IF(WEEKDAY([Date], 2) &amp;lt;= 5, 1, 0)  // Assumes weekends are non-workdays&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Add Cumulative Workday Count&lt;/STRONG&gt;:&lt;UL&gt;&lt;LI&gt;Add a cumulative count of workdays up to each date.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;CumulativeWorkdays = CALCULATE(COUNTROWS('DateTable'), FILTER('DateTable', 'DateTable'[Date] &amp;lt;= EARLIER('DateTable'[Date]) &amp;amp;&amp;amp; 'DateTable'[WorkdayFlag] = 1))&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Calculate Total Workdays Per Month&lt;/STRONG&gt;:&lt;UL&gt;&lt;LI&gt;Add a column to calculate the total workdays for each month.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;TotalWorkdaysMonth = CALCULATE(COUNTROWS('DateTable'), FILTER('DateTable', 'DateTable'[Month] = EARLIER('DateTable'[Month]) &amp;amp;&amp;amp; 'DateTable'[WorkdayFlag] = 1))&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Percentage of Workdays Passed in Current Month&lt;/STRONG&gt;:&lt;UL&gt;&lt;LI&gt;Create a column to calculate the percentage of workdays passed in the current month relative to the total workdays in the month.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;WorkdaysPassedPercentage = 'DateTable'[CumulativeWorkdays] / 'DateTable'[TotalWorkdaysMonth]&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Build the Slicer&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Use the &lt;STRONG&gt;WorkdaysPassedPercentage&lt;/STRONG&gt; column in the slicer to filter dates. When a user selects a number of workdays, the slicer should filter the data based on the relative percentage of workdays passed in each month.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Adjust the Data&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You can also use this percentage logic to align sales or other KPIs by the number of workdays passed, helping to compare performance across months.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;Summary:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Workday Calculation&lt;/STRONG&gt;: Flag workdays and create cumulative workdays.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Month Alignment&lt;/STRONG&gt;: Use total workdays in each month to calculate the percentage of workdays passed.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Slicer&lt;/STRONG&gt;: Use a percentage-based slicer to align workdays across months and compare trends.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This setup allows you to filter data by workdays and easily compare the same number of workdays across different months.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution, this will help others!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If my response(s) assisted you in any way, don't forget to drop me a "&lt;STRONG&gt;Kudos&lt;/STRONG&gt;" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Poojara&lt;BR /&gt;Data Analyst | MSBI Developer | Power BI Consultant&lt;BR /&gt;&lt;STRONG&gt;Please Subscribe my YouTube for Beginners/Advance Concepts:&lt;/STRONG&gt;&amp;nbsp;&lt;A href="https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS" target="_self"&gt;https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Nov 2024 10:24:43 GMT</pubDate>
    <dc:creator>Poojara_D12</dc:creator>
    <dc:date>2024-11-22T10:24:43Z</dc:date>
    <item>
      <title>Date table - Aligning workdays over months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-table-Aligning-workdays-over-months/m-p/4296959#M170590</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just got a request to build a date slicer that "aligns workdays over months", what I mean by this is that if 16 workdays has passed in the current month, the slicer should filter the date table to only show 16 work days in all the previous months as well. The purpose is to make it easier identifing trends in the sales data if you can easily see that "16 days in to May we sold x amount and now in November we sold y amount".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another problem is of course that the number of days differ between months so somehow you need to incorporate the % of passed workdays as a share of total workdays that specific month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It could be added directly in to the date table using m-code or with calculated columns, the main goal is to get the functionality that I am describing. Or maybe there are completely other ways to get the&amp;nbsp;functionality I am after.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be a really good feature to have a slicer like this but I don't really know where to start with this task to be honest, I have searched around but I have not found any information about this. Has anyone else built something similar and/or have any input on how this can be done?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 09:37:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-table-Aligning-workdays-over-months/m-p/4296959#M170590</guid>
      <dc:creator>Jodallen123</dc:creator>
      <dc:date>2024-11-22T09:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Date table - Aligning workdays over months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-table-Aligning-workdays-over-months/m-p/4297021#M170593</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="588595" data-lia-user-login="Jodallen123" class="lia-mention lia-mention-user"&gt;Jodallen123&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To create a &lt;STRONG&gt;workday-aligned date slicer&lt;/STRONG&gt; that works across months in Power BI, follow these steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Create a Date Table&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a &lt;STRONG&gt;Date Table&lt;/STRONG&gt; with all the dates needed, ensuring you have columns for &lt;STRONG&gt;Day of the Week&lt;/STRONG&gt;, &lt;STRONG&gt;Month&lt;/STRONG&gt;, &lt;STRONG&gt;Year&lt;/STRONG&gt;, and &lt;STRONG&gt;Workday Flag&lt;/STRONG&gt; (to indicate whether it's a workday or not).&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Add Workday Column&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Add a column to calculate whether a date is a workday (e.g., weekdays but excluding holidays).&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;WorkdayFlag = IF(WEEKDAY([Date], 2) &amp;lt;= 5, 1, 0)  // Assumes weekends are non-workdays&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Add Cumulative Workday Count&lt;/STRONG&gt;:&lt;UL&gt;&lt;LI&gt;Add a cumulative count of workdays up to each date.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;CumulativeWorkdays = CALCULATE(COUNTROWS('DateTable'), FILTER('DateTable', 'DateTable'[Date] &amp;lt;= EARLIER('DateTable'[Date]) &amp;amp;&amp;amp; 'DateTable'[WorkdayFlag] = 1))&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Calculate Total Workdays Per Month&lt;/STRONG&gt;:&lt;UL&gt;&lt;LI&gt;Add a column to calculate the total workdays for each month.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;TotalWorkdaysMonth = CALCULATE(COUNTROWS('DateTable'), FILTER('DateTable', 'DateTable'[Month] = EARLIER('DateTable'[Month]) &amp;amp;&amp;amp; 'DateTable'[WorkdayFlag] = 1))&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Percentage of Workdays Passed in Current Month&lt;/STRONG&gt;:&lt;UL&gt;&lt;LI&gt;Create a column to calculate the percentage of workdays passed in the current month relative to the total workdays in the month.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;WorkdaysPassedPercentage = 'DateTable'[CumulativeWorkdays] / 'DateTable'[TotalWorkdaysMonth]&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Build the Slicer&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Use the &lt;STRONG&gt;WorkdaysPassedPercentage&lt;/STRONG&gt; column in the slicer to filter dates. When a user selects a number of workdays, the slicer should filter the data based on the relative percentage of workdays passed in each month.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Adjust the Data&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You can also use this percentage logic to align sales or other KPIs by the number of workdays passed, helping to compare performance across months.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;Summary:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Workday Calculation&lt;/STRONG&gt;: Flag workdays and create cumulative workdays.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Month Alignment&lt;/STRONG&gt;: Use total workdays in each month to calculate the percentage of workdays passed.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Slicer&lt;/STRONG&gt;: Use a percentage-based slicer to align workdays across months and compare trends.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This setup allows you to filter data by workdays and easily compare the same number of workdays across different months.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution, this will help others!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If my response(s) assisted you in any way, don't forget to drop me a "&lt;STRONG&gt;Kudos&lt;/STRONG&gt;" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Poojara&lt;BR /&gt;Data Analyst | MSBI Developer | Power BI Consultant&lt;BR /&gt;&lt;STRONG&gt;Please Subscribe my YouTube for Beginners/Advance Concepts:&lt;/STRONG&gt;&amp;nbsp;&lt;A href="https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS" target="_self"&gt;https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 10:24:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-table-Aligning-workdays-over-months/m-p/4297021#M170593</guid>
      <dc:creator>Poojara_D12</dc:creator>
      <dc:date>2024-11-22T10:24:43Z</dc:date>
    </item>
  </channel>
</rss>

