<?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: Is nested sumx the right approach in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-nested-sumx-the-right-approach/m-p/3877742#M151401</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="639489" data-lia-user-login="debenaire" class="lia-mention lia-mention-user"&gt;debenaire&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Nesting SUMX functions can indeed lead to performance issues because it requires iterating over rows multiple times, which can be resource-intensive.&lt;/P&gt;
&lt;P&gt;Instead of nesting SUMX functions, consider restructuring your calculations to minimize the number of row context iterations. You can do this by trying to move calculations outside of the SUMX function if possible.&lt;/P&gt;
&lt;P&gt;So I think you can change the DAX code like this:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR ActualDataCheck = 
    SUMX(
        Points,
        IF(
            ISBLANK([Actual Unit, Cost and Carbon]),
            BLANK(),
            [Actual Unit, Cost and Carbon]
        )
    )

VAR Result = 
    IF(
        ISBLANK(ActualDataCheck),
        CALCULATE(
            MAX(Target[Daily Target]),
            FILTER(
                Target,
                Target[TargetType] = 0
            )
        ),
        ActualDataCheck
    )

RETURN
    SUMX(
        Calendar_,
        Result
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Yilong Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2024 05:15:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-04-30T05:15:25Z</dc:date>
    <item>
      <title>Is nested sumx the right approach</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-nested-sumx-the-right-approach/m-p/3870614#M151186</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created the following measure which provides what i need but performs poorly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measure iterates through each "point" and each row in the calendar to determine if there is "Actual Data". If there is no data, ie. it is blank then it returns the corresponding forecast for the point in question for the day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is nesting these sumx the right thing to do? Thanks in advance:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;calculate(&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;sumx(Calendar_,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SUMX(Points,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;IF(&lt;SPAN&gt;ISBLANK(&lt;SPAN&gt;[Actual Unit, Cost and Carbon]),&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;calculate(&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; max(Target[Daily Target]),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CROSSFILTER(Points[DBName-Point_Id],Target[DBName-Point_Id],&lt;SPAN&gt;OneWay_LeftFiltersRight))))),&lt;SPAN&gt;FILTER(Target,Target[TargetType] = &lt;SPAN&gt;0))&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 09:01:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-nested-sumx-the-right-approach/m-p/3870614#M151186</guid>
      <dc:creator>debenaire</dc:creator>
      <dc:date>2024-04-26T09:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is nested sumx the right approach</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-nested-sumx-the-right-approach/m-p/3870657#M151189</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="639489" data-lia-user-login="debenaire" class="lia-mention lia-mention-user"&gt;debenaire&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;In general does not look good. But how does your model look like? how does your report look like? and confirm&amp;nbsp;&lt;SPAN&gt;[Actual Unit, Cost and Carbon] is a measure.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 09:19:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-nested-sumx-the-right-approach/m-p/3870657#M151189</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2024-04-26T09:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Is nested sumx the right approach</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-nested-sumx-the-right-approach/m-p/3877742#M151401</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="639489" data-lia-user-login="debenaire" class="lia-mention lia-mention-user"&gt;debenaire&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Nesting SUMX functions can indeed lead to performance issues because it requires iterating over rows multiple times, which can be resource-intensive.&lt;/P&gt;
&lt;P&gt;Instead of nesting SUMX functions, consider restructuring your calculations to minimize the number of row context iterations. You can do this by trying to move calculations outside of the SUMX function if possible.&lt;/P&gt;
&lt;P&gt;So I think you can change the DAX code like this:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR ActualDataCheck = 
    SUMX(
        Points,
        IF(
            ISBLANK([Actual Unit, Cost and Carbon]),
            BLANK(),
            [Actual Unit, Cost and Carbon]
        )
    )

VAR Result = 
    IF(
        ISBLANK(ActualDataCheck),
        CALCULATE(
            MAX(Target[Daily Target]),
            FILTER(
                Target,
                Target[TargetType] = 0
            )
        ),
        ActualDataCheck
    )

RETURN
    SUMX(
        Calendar_,
        Result
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Yilong Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 05:15:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-nested-sumx-the-right-approach/m-p/3877742#M151401</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-30T05:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Is nested sumx the right approach</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-nested-sumx-the-right-approach/m-p/3877894#M151404</link>
      <description>&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 06:05:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-nested-sumx-the-right-approach/m-p/3877894#M151404</guid>
      <dc:creator>debenaire</dc:creator>
      <dc:date>2024-04-30T06:05:56Z</dc:date>
    </item>
  </channel>
</rss>

