<?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 Help with Optimizing Measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2165085#M50141</link>
    <description>&lt;P&gt;Hi, I need help to optimize this measure that returns the working days between two dates. There was no issue when the dataset was a month's worth (~200k rows) but since I added more months (now at 3M+ rows) it is taking too long, sometimes coming up with error "not enough memory to process..." Appreciate any help please.&lt;/P&gt;&lt;P&gt;Let me know if you need access to file (353MB)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Job to Accep Working Days = 
var _d_jbook = DATEVALUE( Minx('FreightForward v2', [JOB_BOOKING_DATETIME]))
var _d_accept = if ( Maxx('FreightForward v2', [ACCEPTANCE_DATETIME]) = blank(), blank(), DATEVALUE( Maxx('FreightForward v2', [ACCEPTANCE_DATETIME] ) ))
var _d_end = if (ISBLANK(_d_accept) || _d_jbook &amp;gt; _d_accept, _d_jbook, _d_accept)
var _workdays = CALCULATE( countrows( 'Calendar Job Booking'), 
                    DATESBETWEEN('Calendar Job Booking'[Date], _d_jbook, _d_end), 
                    FILTER('Calendar Job Booking', 'Calendar Job Booking'[WorkingDay] = "yes")
                    )
RETURN if (ISBLANK(_d_accept), blank(), _workdays -1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 31 Oct 2021 21:59:54 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-10-31T21:59:54Z</dc:date>
    <item>
      <title>Help with Optimizing Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2165085#M50141</link>
      <description>&lt;P&gt;Hi, I need help to optimize this measure that returns the working days between two dates. There was no issue when the dataset was a month's worth (~200k rows) but since I added more months (now at 3M+ rows) it is taking too long, sometimes coming up with error "not enough memory to process..." Appreciate any help please.&lt;/P&gt;&lt;P&gt;Let me know if you need access to file (353MB)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Job to Accep Working Days = 
var _d_jbook = DATEVALUE( Minx('FreightForward v2', [JOB_BOOKING_DATETIME]))
var _d_accept = if ( Maxx('FreightForward v2', [ACCEPTANCE_DATETIME]) = blank(), blank(), DATEVALUE( Maxx('FreightForward v2', [ACCEPTANCE_DATETIME] ) ))
var _d_end = if (ISBLANK(_d_accept) || _d_jbook &amp;gt; _d_accept, _d_jbook, _d_accept)
var _workdays = CALCULATE( countrows( 'Calendar Job Booking'), 
                    DATESBETWEEN('Calendar Job Booking'[Date], _d_jbook, _d_end), 
                    FILTER('Calendar Job Booking', 'Calendar Job Booking'[WorkingDay] = "yes")
                    )
RETURN if (ISBLANK(_d_accept), blank(), _workdays -1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 21:59:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2165085#M50141</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-31T21:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Optimizing Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2165102#M50142</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you share a sample of your data in the table format [to be able to copy and paste that]?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Appreciate your Kudos!!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 22:33:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2165102#M50142</guid>
      <dc:creator>VahidDM</dc:creator>
      <dc:date>2021-10-31T22:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Optimizing Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2165108#M50143</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="315278" data-lia-user-login="VahidDM" class="lia-mention lia-mention-user"&gt;VahidDM&lt;/a&gt; , here is sample file with reduced dataset - 1month only&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/drive/folders/1dmmbhdbzySZBr8oTxj9CWsmztwFQ3f8A?usp=sharing" target="_blank"&gt;https://drive.google.com/drive/folders/1dmmbhdbzySZBr8oTxj9CWsmztwFQ3f8A?usp=sharing&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 22:41:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2165108#M50143</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-31T22:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Optimizing Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2166051#M50189</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the baseline performance of your measure:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;5.8s to run, but more importantly 5 SE (Storage Engine) queries of which 3 are tables with a large number of rows.&amp;nbsp; Reducing the number of queries and/or their size should be the aim as that's what will improve performance.&lt;/P&gt;
&lt;P&gt;That leads to the first thing you can do - split your datetime fields into a date field and a time field.&amp;nbsp; The SE queries with 300k rows are because you're using datetime fields in your visual, but the time has no bearing on this calculation.&lt;/P&gt;
&lt;P&gt;If you were to use the same measure on a visual with JOB_BOOKING_DATE and ACCEPTANCE_DATE (new date fields) then you'd get this performance:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Down to 42ms.&amp;nbsp; Same number of SE Queries but they're much smaller.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A second thing that occurs to me is does this need to be a measure or could it be a calculated column?&amp;nbsp; Having the working days pre-calculated is&amp;nbsp;always going to be quicker than a measure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 10:42:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2166051#M50189</guid>
      <dc:creator>PaulOlding</dc:creator>
      <dc:date>2021-11-01T10:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Optimizing Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2167073#M50255</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="150936" data-lia-user-login="PaulOlding" class="lia-mention lia-mention-user"&gt;PaulOlding&lt;/a&gt; , thanks for clarifying the issue. I used custom column before but the expected results were not correct however I've managed to get it to work now and everything works fine.&lt;/P&gt;&lt;P&gt;I have a question if you're able to assist please. I have another measure that displays jobs by working days as per screenshot below but I want to group working days &amp;gt;=10 and show as 10+ i.e. it will sum jobs &amp;gt;=10 so for the screenshot example, the expected result will show value of 167(29+2+4+74+14+2+1+41) for 10+&lt;/P&gt;&lt;P&gt;Here's link to sample file&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/drive/folders/1dmmbhdbzySZBr8oTxj9CWsmztwFQ3f8A?usp=sharing" target="_blank" rel="noopener"&gt;https://drive.google.com/drive/folders/1dmmbhdbzySZBr8oTxj9CWsmztwFQ3f8A?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 22:07:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2167073#M50255</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-01T22:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Optimizing Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2168204#M50303</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll need a couple of extra columns to do this.&amp;nbsp; One to hold days with "10+" for results &amp;gt; 10, and a second column to hold the sort order for the first column.&lt;/P&gt;
&lt;P&gt;They're both very similar to your existing&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;Job to Accep Working Days column&lt;/SPAN&gt;, just altering the RETURN part.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Job to Accep Working Days (10max) = 
var _d_jbook = DATEVALUE( [JOB_BOOKING_DATETIME])
var _d_accept = if ( [ACCEPTANCE_DATETIME] = blank(), blank(), DATEVALUE( [ACCEPTANCE_DATETIME] ))
var _d_end = if (ISBLANK(_d_accept) || _d_jbook &amp;gt; _d_accept, _d_jbook, _d_accept)
var _workdays = CALCULATE( countrows( 'Calendar Job Booking'), 
                    DATESBETWEEN('Calendar Job Booking'[Date], _d_jbook, _d_end), 
                    FILTER('Calendar Job Booking', 'Calendar Job Booking'[WorkingDay] = "yes")
                    )
RETURN 
if (ISBLANK(_d_accept), 
    blank(),
    IF(_workdays -1 &amp;gt;=10, 
        "10+",
        FORMAT(_workdays -1, "#")
    )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Job to Accep Working Days (10max) Order = 
var _d_jbook = DATEVALUE( [JOB_BOOKING_DATETIME])
var _d_accept = if ( [ACCEPTANCE_DATETIME] = blank(), blank(), DATEVALUE( [ACCEPTANCE_DATETIME] ))
var _d_end = if (ISBLANK(_d_accept) || _d_jbook &amp;gt; _d_accept, _d_jbook, _d_accept)
var _workdays = CALCULATE( countrows( 'Calendar Job Booking'), 
                    DATESBETWEEN('Calendar Job Booking'[Date], _d_jbook, _d_end), 
                    FILTER('Calendar Job Booking', 'Calendar Job Booking'[WorkingDay] = "yes")
                    )
RETURN 
if (ISBLANK(_d_accept), 
    blank(),
    IF(_workdays -1 &amp;gt;=10, 
        10,
        _workdays -1
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;You then set the sort order for the&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;Job to Accep Working Days (10max) column in the Data view.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Final result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 10:34:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2168204#M50303</guid>
      <dc:creator>PaulOlding</dc:creator>
      <dc:date>2021-11-02T10:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Optimizing Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2169280#M50343</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="150936" data-lia-user-login="PaulOlding" class="lia-mention lia-mention-user"&gt;PaulOlding&lt;/a&gt;, perfect that worked. Cool ninja stuff with the first measure with no values showing but acting as a 'holding' / 'storage' column. Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 19:57:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-Optimizing-Measure/m-p/2169280#M50343</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-02T19:57:45Z</dc:date>
    </item>
  </channel>
</rss>

