<?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 Rewrite Filter function with better option (Optimize Dax Measure) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1032542#M13626</link>
    <description>&lt;P&gt;Hi Guys! I need your help please,&lt;BR /&gt;I have a model and I need to calculate a Sum of a column as a measure,&amp;nbsp;the measure works fine, shows me the correct number,&lt;BR /&gt;but when I begin to use other dimensions, the time expended for the visual&amp;nbsp;that use this metric begin to increase (the visual has only that measure),&amp;nbsp;so I was analyzing the measure, and I find the filter that makes the visual slower (is a filter in the metric), it's highlighted in another image, so I want to replace that filter, but I don't know-how, can you give me any advice?&amp;nbsp; &amp;nbsp;Below you can find the measure, the model and the current results of a visualization (that are correct).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Apr 2020 13:59:19 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-04-17T13:59:19Z</dc:date>
    <item>
      <title>Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1032542#M13626</link>
      <description>&lt;P&gt;Hi Guys! I need your help please,&lt;BR /&gt;I have a model and I need to calculate a Sum of a column as a measure,&amp;nbsp;the measure works fine, shows me the correct number,&lt;BR /&gt;but when I begin to use other dimensions, the time expended for the visual&amp;nbsp;that use this metric begin to increase (the visual has only that measure),&amp;nbsp;so I was analyzing the measure, and I find the filter that makes the visual slower (is a filter in the metric), it's highlighted in another image, so I want to replace that filter, but I don't know-how, can you give me any advice?&amp;nbsp; &amp;nbsp;Below you can find the measure, the model and the current results of a visualization (that are correct).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 13:59:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1032542#M13626</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-17T13:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1034110#M13682</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;var __maxMonthId = MAX( Work[month_id] )
var __result =
	CALCULATE(
		SUM( Work[pct_assignment_monthly] ),
		KEEPFILTERS( 'Calendar'[month_id] = __maxMonthId ),
		KEEPFILTERS(
			TREATAS(
				{1002, -1, 1001},
				Project[project_category]
			)
		)
	)
return
	__result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 16:44:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1034110#M13682</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-18T16:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1044921#M14082</link>
      <description>&lt;P&gt;Thanks for the answer and sorry for my late response, I'd change the measure as you advise, but the time still increasing every time I add a new dimension, so I traced both measures, and there are the results:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the Trace using your proposed measure (use more FE than SE):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the trace using the first version of the measure (a little bit better un FE usage, but make 1 SE Query compared with the newest version of the measure)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, another idea to replace the measure?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 16:16:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1044921#M14082</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-23T16:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1044972#M14084</link>
      <description>&lt;P&gt;As an important finding, the filter that makes it slower is when evaluate Max(Month_id)&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 16:27:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1044972#M14084</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-23T16:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045007#M14087</link>
      <description>Wait... What is the query that you measure? If you are pulling out of the model a lot of detail rows, then no wonder this is slow. I'd be surprised if you pulled out a fairly small amount rows from your dimensions and got such results as above. I smell something fishy in the query because my measure does not use fancy math, only filtering and therefore SE should prevail. In the measure there's not even a single IF that would call for a CALLBACK.&lt;BR /&gt;&lt;BR /&gt;Please show us the query and tell us how many rows you pull out.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Thu, 23 Apr 2020 16:51:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045007#M14087</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-23T16:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045037#M14088</link>
      <description>&lt;P&gt;These are the queries that I measured:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;With your measure:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;DEFINE&lt;BR /&gt;---- MODEL MEASURES BEGIN ----&lt;BR /&gt;MEASURE Work[Load] =&lt;BR /&gt;var maxMonthId = MAX( Work[month_id] )&lt;BR /&gt;var result =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM( Work[pct_assigment_monthly] ),&lt;BR /&gt;KEEPFILTERS( 'Calendar'[month_id] = maxMonthId ),&lt;BR /&gt;KEEPFILTERS(&lt;BR /&gt;TREATAS(&lt;BR /&gt;{1002, -1, 1001},&lt;BR /&gt;Project[project_category]&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;return&lt;BR /&gt;result&lt;BR /&gt;---- MODEL MEASURES END ----&lt;/P&gt;&lt;P&gt;VAR __DS0FilterTable =&lt;BR /&gt;TREATAS({2020}, 'Calendar'[Year])&lt;/P&gt;&lt;P&gt;EVALUATE&lt;BR /&gt;SUMMARIZECOLUMNS(&lt;BR /&gt;ROLLUPADDISSUBTOTAL(&lt;BR /&gt;ROLLUPGROUP(&lt;BR /&gt;'Calendar'[month_description],&lt;BR /&gt;'Calendar'[month_id],&lt;BR /&gt;'Regions'[region_desc],&lt;BR /&gt;'Machine Sector'[sector_desc],&lt;BR /&gt;'Customer'[customer_desc]&lt;BR /&gt;), "IsGrandTotalRowTotal"&lt;BR /&gt;),&lt;BR /&gt;__DS0FilterTable,&lt;BR /&gt;"Load", 'Work'[Load]&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;With the first version of the measure (I only changed maxMonthId in order to use as a variable):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;DEFINE&lt;BR /&gt;---- MODEL MEASURES BEGIN ----&lt;BR /&gt;MEASURE Work[Load] =&lt;BR /&gt;VAR maxMonthid =&lt;BR /&gt;MAX ( 'Work'[month_id] )&lt;BR /&gt;VAR result =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM ( Work[pct_assigment_monthly] ),&lt;BR /&gt;FILTER ( 'Calendar', maxMonthid = 'Calendar'[month_id] ),&lt;BR /&gt;FILTER (&lt;BR /&gt;Project,&lt;BR /&gt;Project[project_category] = 1001&lt;BR /&gt;|| Project[project_category] = 1002&lt;BR /&gt;|| Project[project_category] = -1&lt;BR /&gt;),&lt;BR /&gt;CROSSFILTER ( 'Leave Reason'[leave_reason_id], Work[leave_reason], NONE )&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;result&lt;/P&gt;&lt;P&gt;---- MODEL MEASURES END ----&lt;BR /&gt;VAR __DS0FilterTable =&lt;BR /&gt;TREATAS ( { 2020 }, 'Calendar'[Year] )&lt;BR /&gt;EVALUATE&lt;BR /&gt;SUMMARIZECOLUMNS (&lt;BR /&gt;ROLLUPADDISSUBTOTAL (&lt;BR /&gt;ROLLUPGROUP (&lt;BR /&gt;'Calendar'[month_description],&lt;BR /&gt;'Calendar'[month_id],&lt;BR /&gt;'Regions'[region_desc],&lt;BR /&gt;'Machine Sector'[sector_desc],&lt;BR /&gt;'Customer'[customer_desc]&lt;BR /&gt;),&lt;BR /&gt;"IsGrandTotalRowTotal"&lt;BR /&gt;),&lt;BR /&gt;__DS0FilterTable,&lt;BR /&gt;"Load", 'Work'[Load]&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 17:22:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045037#M14088</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-23T17:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045040#M14089</link>
      <description>OK. How many rows are you pulling out in total?&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Thu, 23 Apr 2020 17:14:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045040#M14089</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-23T17:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045071#M14090</link>
      <description>&lt;P&gt;4371 rows (including the total), if I put all dimensions of the model, the result will be bigger, the fact table has 730K rows.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 17:30:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045071#M14090</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-23T17:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045089#M14091</link>
      <description>Yeah... This is a lot of rows. For a reporting tool that should summarize data, this is really unusual to return that many rows. Also, the speed depends on the hardware you use.&lt;BR /&gt;&lt;BR /&gt;I suppose that for a decent amount of rows the measure will be very fast.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Thu, 23 Apr 2020 17:36:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045089#M14091</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-23T17:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045113#M14092</link>
      <description>&lt;P&gt;But everything works fine if I remove the Date filter, this one:&amp;nbsp;&amp;nbsp; &lt;SPAN&gt;FILTER ( 'Date', maxMonthid = 'Date'[Month ID] )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously, the result of the measure doesn't work for me.&amp;nbsp; So, there is another idea to replace it?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 17:53:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1045113#M14092</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-23T17:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite Filter function with better option (Optimize Dax Measure)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1086117#M15516</link>
      <description>&lt;P&gt;I can solve it using lastnonblank function, everything works fine now&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 13:54:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rewrite-Filter-function-with-better-option-Optimize-Dax-Measure/m-p/1086117#M15516</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-12T13:54:37Z</dc:date>
    </item>
  </channel>
</rss>

