<?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: Find Date X days in the Future, Skipping Non-WorkDays in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4147708#M164821</link>
    <description>&lt;P&gt;So, Good News: this solution works! The Bad News, though: it is very slow, taking over ten seconds even on my small ~15,000 row dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a more efficient way of accomplishing this same task?&lt;/P&gt;</description>
    <pubDate>Thu, 12 Sep 2024 15:56:48 GMT</pubDate>
    <dc:creator>Brightsider</dc:creator>
    <dc:date>2024-09-12T15:56:48Z</dc:date>
    <item>
      <title>Find Date X days in the Future, Skipping Non-WorkDays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4145768#M164746</link>
      <description>&lt;P&gt;So, I'm building a calculation to dynamically calculate whether a given item of work was delivered inside of our Service Level Agreement or not: if the item of work if a First Request, it must be turned around in two business days. If it is a Rework, it must be turned around in one business day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To find this, I want to take the date the item of work landed on the desk of our employee, and add the one or two days to that date to find the date we must turn the item of work around in to be in SLA. Easy enough, but I need this measure to only count business days, skipping holidays and weekends.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a Date table with an Is Workday function pre-calculated, so that's done, but my problem is: how do I find the proper date consistently? Here is my current attempt at it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ADDCOLUMNS(
	FILTER('Opportunity State History', 'Opportunity State History'[csa_newstatename] = "Proposal Request"),
	"InSLA",
	VAR StartDate = 'Opportunity State History'[csa_newstatedatetime]
	VAR requestSLAgoal = IF('Opportunity State History'[proposalrequesttype] = "Rework", 1, 2)
	VAR SLAdate =
	CONCATENATE(
		CALCULATE(
			MINX(_Dates, _Dates[Date]),
			DATESBETWEEN(_Dates[Date], StartDate + requestSLAGoal, 'Opportunity State History'[csa_newstatedate] + 7),
			_Dates[Is Workday] = TRUE
		),
		" " &amp;amp; TIMEVALUE(StartDate)
	)
	VAR SLAdatetime = 
		DATEVALUE(SLAdate) + TIMEVALUE(SLAdate)
	RETURN
	IF(
			IF(
			ISBLANK('Opportunity State History'[csa_nextstatedate]),
			TODAY() &amp;lt; SLAdatetime,
			'Opportunity State History'[csa_nextstatedate] &amp;lt; SLAdatetime
			),
		True,
		False
	)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This&amp;nbsp;&lt;EM&gt;kind of&amp;nbsp;&lt;/EM&gt;works: For each item of work, it generates a list dates between when it was submitted and and week later, filters those dates down to only include Workdays, and then selected the smallest date that is at least the number of days away from the submission date as the SLA turnaround time of 1 or 2 days. The problem is fridays: If a two-day turnaround item is submitted Friday, the smallest date greater than that returns as Monday instead of Tuesday. Which is&amp;nbsp;&lt;EM&gt;correct &lt;/EM&gt;but not what I want.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;To remedy this, I envision a procedure of still generating the list of dates, and then doing a running total of workdays. Something like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Is Work Day?&lt;/TD&gt;&lt;TD&gt;Workday Total&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/15/2024&lt;/TD&gt;&lt;TD&gt;False&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/16/2024&lt;/TD&gt;&lt;TD&gt;False&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/17/2024&lt;/TD&gt;&lt;TD&gt;True&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/18/2024&lt;/TD&gt;&lt;TD&gt;True&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/19/2024&lt;/TD&gt;&lt;TD&gt;True&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/20/2024&lt;/TD&gt;&lt;TD&gt;True&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then just using SELECTCOLUMNS to select the row with a value equal to the turnaround time (For a 2 day turnaound, it would be row 4, 6/18/2024).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But... I don't quite know how to do that. Anythought on how to generate something like that (or if there's just a more efficient way of doing what I'm trying to do?)&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 23:10:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4145768#M164746</guid>
      <dc:creator>Brightsider</dc:creator>
      <dc:date>2024-09-11T23:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Find Date X days in the Future, Skipping Non-WorkDays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4146370#M164767</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="755400" data-lia-user-login="Brightsider" class="lia-mention lia-mention-user"&gt;Brightsider&lt;/a&gt;&amp;nbsp;, Try using below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ADDCOLUMNS(&lt;BR /&gt;FILTER('Opportunity State History', 'Opportunity State History'[csa_newstatename] = "Proposal Request"),&lt;BR /&gt;"InSLA",&lt;BR /&gt;VAR StartDate = 'Opportunity State History'[csa_newstatedatetime]&lt;BR /&gt;VAR requestSLAgoal = IF('Opportunity State History'[proposalrequesttype] = "Rework", 1, 2)&lt;BR /&gt;VAR SLAdate =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MINX(&lt;BR /&gt;FILTER(&lt;BR /&gt;ADDCOLUMNS(&lt;BR /&gt;_Dates,&lt;BR /&gt;"WorkdayTotal",&lt;BR /&gt;SUMX(&lt;BR /&gt;FILTER(&lt;BR /&gt;_Dates,&lt;BR /&gt;_Dates[Date] &amp;lt;= EARLIER(_Dates[Date]) &amp;amp;&amp;amp; _Dates[Is Workday] = TRUE&lt;BR /&gt;),&lt;BR /&gt;1&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;[WorkdayTotal] = requestSLAgoal&lt;BR /&gt;),&lt;BR /&gt;_Dates[Date]&lt;BR /&gt;),&lt;BR /&gt;_Dates[Date] &amp;gt;= StartDate&lt;BR /&gt;)&lt;BR /&gt;VAR SLAdatetime = &lt;BR /&gt;DATEVALUE(SLAdate) + TIMEVALUE(StartDate)&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;IF(&lt;BR /&gt;ISBLANK('Opportunity State History'[csa_nextstatedate]),&lt;BR /&gt;TODAY() &amp;lt; SLAdatetime,&lt;BR /&gt;'Opportunity State History'[csa_nextstatedate] &amp;lt; SLAdatetime&lt;BR /&gt;),&lt;BR /&gt;TRUE,&lt;BR /&gt;FALSE&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 06:41:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4146370#M164767</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2024-09-12T06:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Find Date X days in the Future, Skipping Non-WorkDays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4146974#M164786</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="755400" data-lia-user-login="Brightsider" class="lia-mention lia-mention-user"&gt;Brightsider&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Did &lt;STRONG&gt;bhanu_gautam&lt;/STRONG&gt; reply solve your problem? If so, please mark it as the correct solution, and point out if the problem persists(just like provide test data about your data model).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Adamk Kong&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 10:40:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4146974#M164786</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-12T10:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Find Date X days in the Future, Skipping Non-WorkDays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4147708#M164821</link>
      <description>&lt;P&gt;So, Good News: this solution works! The Bad News, though: it is very slow, taking over ten seconds even on my small ~15,000 row dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a more efficient way of accomplishing this same task?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 15:56:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4147708#M164821</guid>
      <dc:creator>Brightsider</dc:creator>
      <dc:date>2024-09-12T15:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Find Date X days in the Future, Skipping Non-WorkDays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4162962#M165390</link>
      <description>&lt;P&gt;Quick update, I made a more efficient version of the initial solution:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EVALUATE 
ADDCOLUMNS(
	FILTER('Opportunity State History', 'Opportunity State History'[csa_newstatename] = "Proposal Request"),
	"InSLA",
	VAR StartDate = COALESCE('Opportunity State History'[csa_newstatedate], 'Opportunity State History'[csa_newstatedatetime])
	VAR requestSLAgoal = IF('Opportunity State History'[proposalrequesttype] = "Rework", 1, 2)
	VAR WorkingDays =
		SELECTCOLUMNS(
				FILTER(
				ALL(_Dates),
				_Dates[Date] &amp;gt; StartDate &amp;amp;&amp;amp;
				_Dates[Date] &amp;lt;= (StartDate + 7) &amp;amp;&amp;amp;
				_Dates[Is Workday] = TRUE
			),
			[Date]
		)
	VAR SLAdate =
		INDEX(
			requestSLAgoal,
			WorkingDays,
		)
	VAR SLAdatetime = DATEVALUE(SLAdate) + TIMEVALUE(StartDate)
	RETURN
	IF(
		IF(
			ISBLANK('Opportunity State History'[csa_nextstatedate]),
			TODAY() &amp;lt; SLAdatetime,
			'Opportunity State History'[csa_nextstatedate] &amp;lt; SLAdatetime
		),
		TRUE,
		FALSE
	)
)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using a Variable with the Index function got it to run in under a second.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 16:10:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-Date-X-days-in-the-Future-Skipping-Non-WorkDays/m-p/4162962#M165390</guid>
      <dc:creator>Brightsider</dc:creator>
      <dc:date>2024-09-20T16:10:28Z</dc:date>
    </item>
  </channel>
</rss>

