<?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: Function that returns next business day based on today's date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/2764816#M85846</link>
    <description>&lt;P&gt;For a Power Query solution you can do something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;= Date.AddDays(
  Date.From( DateTime.LocalNow() ), increase the current date
  1                    // by one day 
   + List.Count(       // + the number of
      List.Generate(   // weekenddays
         () =&amp;gt; Date.AddDays( [Date], 1 ),
         each Date.DayOfWeek(_, Day.Monday) &amp;gt;= 5,
         each Date.AddDays(_, 1)
      )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a more robust custom power query function you can also use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
  WorkDayOffset = 1,
  AddDays = Number.Sign( WorkDayOffset ),
  NumOfWD = Number.Abs( WorkDayOffset ),
  Holidays = {#date( 2022, 9, 19 )},
  Today = Date.From( DateTime.LocalNow() ),
  ListOfDates =
    List.Generate(
      () =&amp;gt; [ Date = Date.AddDays( Today, AddDays ),
              WD_Counter = 0,
              IsWorkday = null
            ],
      each if [WD_Counter] = NumOfWD 
         and [IsWorkday] = true then false else true,
      each  [
              Date       = Date.AddDays( [Date], AddDays ),
              WD_Counter = if Date.DayOfWeek( [Date], 1 ) &amp;lt; 5
                              and not List.Contains( Holidays , [Date] )
                              then [WD_Counter] + 1 else [WD_Counter],
              IsWorkday  = Date.DayOfWeek( [Date], 1 ) &amp;lt; 5
                              and not List.Contains( Holidays, [Date] )
            ],
      each [Date]
    ),
  RelevantWorkDay=  List.Last(  ListOfDates )
in
  RelevantWorkDay&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make sure it respects holidays, you should adjust the 'Holidays' parameter as described here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://gorilla.bi/power-query/nth-business-day-from-date/" target="_blank" rel="noopener"&gt;Calculate Nth Business Day From Date in Power Query - BI Gorilla&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rick&lt;/P&gt;&lt;P&gt;--------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;I&gt;@ me in replies or I'll lose your thread&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Master Power Query M? &lt;/STRONG&gt;-&amp;gt; &lt;A href="https://powerquery.how" target="_blank"&gt;https://powerquery.how&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Read in-depth articles? &lt;/STRONG&gt;-&amp;gt; &lt;A href="https://gorilla.bi" target="_blank"&gt;BI Gorilla&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Youtube Channel: &lt;/STRONG&gt;&lt;A href="https://www.youtube.com/channel/UCxc-6L_IdxVphs4fn6cVeEQ" target="_blank"&gt;BI Gorilla&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this post helps, then please consider accepting it as the solution to help other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2023 16:28:40 GMT</pubDate>
    <dc:creator>Rickmaurinus</dc:creator>
    <dc:date>2023-07-25T16:28:40Z</dc:date>
    <item>
      <title>Function that returns next business day based on today's date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/1129878#M16719</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Example: Today is 05/29, the function should return the next working day will be 06/01.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone have any idea how this can be done in dax?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thank you&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 17:18:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/1129878#M16719</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-29T17:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Function that returns next business day based on today's date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/1129942#M16723</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Probably best to have a calendar table that has a column indicating whether a day is a business day. Then you could obtain the next business date with&amp;nbsp;something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALCULATE (
    MIN ( CalendarTable[Date] ),
    FILTER (
        ALL ( CalendarTable[Date], CalendarTable[isBusiness] ),
        CalendarTable[Date] &amp;gt; TODAY ()
            &amp;amp;&amp;amp; CalendarTable[isBusiness] = "Yes"
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please mark the question solved when done and consider &lt;FONT color="#FF9900"&gt;giving kudos if posts are helpful.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;Contact me privately for support with any larger-scale BI needs, tutoring, etc.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Cheers&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 17:57:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/1129942#M16723</guid>
      <dc:creator>AlB</dc:creator>
      <dc:date>2020-05-29T17:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Function that returns next business day based on today's date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/1129963#M16724</link>
      <description>&lt;P&gt;I don't factor in Holidays, but for eliminating the weekends:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(WEEKDAY([date],2)&amp;lt;5,[date] + 1,[date] + (8 - WEEKDAY([date],2)))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 29 May 2020 17:51:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/1129963#M16724</guid>
      <dc:creator>MarcelWoodman</dc:creator>
      <dc:date>2020-05-29T17:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Function that returns next business day based on today's date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/2764816#M85846</link>
      <description>&lt;P&gt;For a Power Query solution you can do something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;= Date.AddDays(
  Date.From( DateTime.LocalNow() ), increase the current date
  1                    // by one day 
   + List.Count(       // + the number of
      List.Generate(   // weekenddays
         () =&amp;gt; Date.AddDays( [Date], 1 ),
         each Date.DayOfWeek(_, Day.Monday) &amp;gt;= 5,
         each Date.AddDays(_, 1)
      )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a more robust custom power query function you can also use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
  WorkDayOffset = 1,
  AddDays = Number.Sign( WorkDayOffset ),
  NumOfWD = Number.Abs( WorkDayOffset ),
  Holidays = {#date( 2022, 9, 19 )},
  Today = Date.From( DateTime.LocalNow() ),
  ListOfDates =
    List.Generate(
      () =&amp;gt; [ Date = Date.AddDays( Today, AddDays ),
              WD_Counter = 0,
              IsWorkday = null
            ],
      each if [WD_Counter] = NumOfWD 
         and [IsWorkday] = true then false else true,
      each  [
              Date       = Date.AddDays( [Date], AddDays ),
              WD_Counter = if Date.DayOfWeek( [Date], 1 ) &amp;lt; 5
                              and not List.Contains( Holidays , [Date] )
                              then [WD_Counter] + 1 else [WD_Counter],
              IsWorkday  = Date.DayOfWeek( [Date], 1 ) &amp;lt; 5
                              and not List.Contains( Holidays, [Date] )
            ],
      each [Date]
    ),
  RelevantWorkDay=  List.Last(  ListOfDates )
in
  RelevantWorkDay&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make sure it respects holidays, you should adjust the 'Holidays' parameter as described here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://gorilla.bi/power-query/nth-business-day-from-date/" target="_blank" rel="noopener"&gt;Calculate Nth Business Day From Date in Power Query - BI Gorilla&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rick&lt;/P&gt;&lt;P&gt;--------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;I&gt;@ me in replies or I'll lose your thread&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Master Power Query M? &lt;/STRONG&gt;-&amp;gt; &lt;A href="https://powerquery.how" target="_blank"&gt;https://powerquery.how&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Read in-depth articles? &lt;/STRONG&gt;-&amp;gt; &lt;A href="https://gorilla.bi" target="_blank"&gt;BI Gorilla&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Youtube Channel: &lt;/STRONG&gt;&lt;A href="https://www.youtube.com/channel/UCxc-6L_IdxVphs4fn6cVeEQ" target="_blank"&gt;BI Gorilla&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this post helps, then please consider accepting it as the solution to help other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 16:28:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/2764816#M85846</guid>
      <dc:creator>Rickmaurinus</dc:creator>
      <dc:date>2023-07-25T16:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Function that returns next business day based on today's date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/3169779#M114217</link>
      <description>&lt;P&gt;This seems to be giving me back tomorrow for every row on my table.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 15:18:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Function-that-returns-next-business-day-based-on-today-s-date/m-p/3169779#M114217</guid>
      <dc:creator>michaelu1</dc:creator>
      <dc:date>2023-04-03T15:18:02Z</dc:date>
    </item>
  </channel>
</rss>

