<?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: SUM measure for multiple partitions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3160814#M113509</link>
    <description>&lt;P&gt;Works! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Just Instead of&lt;/P&gt;&lt;LI-CODE lang="php"&gt;VAR ChosenCats = ALLSELECTED( 'MyTable'[SubCategory1], 'MyTable'[SubCategory2], 'MyTable'[SubCategory3])&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;recommend to use&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;VAR ChosenCats = ALLSELECTED( MyTable )&lt;/LI-CODE&gt;&lt;P&gt;It looks like more generic solution&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2023 12:37:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-03-29T12:37:38Z</dc:date>
    <item>
      <title>SUM measure for multiple partitions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3158761#M113371</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to create SUM measure on multiple partitions?&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt;&amp;nbsp;(that almost works as estimated)&lt;BR /&gt;&lt;STRONG&gt;Task&lt;/STRONG&gt;: create measure, that will provide Sum of values based on 2 partitions (SubCategory1, SubCategory2)&lt;BR /&gt;Like on this screen:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;Measure definition (thanks to &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;, details &lt;A href="https://stackoverflow.com/a/49323268/6165594" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;m1 subCtgVal 1,2 = 
VAR Result =
    CALCULATE(
        SUM(MyTable[Value]),
        ALLSELECTED(MyTable), -- Removes RowContext Transition 
        SUMMARIZE(
            MyTable,
            MyTable[SubCategory1], -- Partition1
            MyTable[SubCategory2]  -- Partition2
        )
    )
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;&lt;STRONG&gt;Problem&lt;/STRONG&gt;: it works as estimated only until you touch SubCategory3 filter.&lt;BR /&gt;When you use&amp;nbsp;SubCategory3 filter, it behaves like 3 partition SUM ((SubCategory1, SubCategory2, SubCategory3):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Please help to fix if possible.&lt;BR /&gt;&lt;STRONG&gt;Source&lt;/STRONG&gt; (&lt;A href="https://github.com/DenisSipchenko/Power-BI/blob/9d6e4a60f4858e457030c4db5c7e0ef7119eb039/Questions/DAX_SQL_OverPartitionBy.pbix" target="_self"&gt;Download&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 14:34:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3158761#M113371</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-28T14:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: SUM measure for multiple partitions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3158851#M113376</link>
      <description>&lt;LI-CODE lang="markup"&gt;m1 subCtgVal 1,2 = 
VAR Result =
    CALCULATE(
        SUM(MyTable[Value]),
        ALLEXCEPT(MyTable, MyTable[SubCategory1], MyTable[SubCategory2]), -- Removes RowContext Transition 
        SUMMARIZE(
            MyTable,
            MyTable[SubCategory1], -- Partition1
            MyTable[SubCategory2]  -- Partition2
        )
    )
RETURN Result&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 28 Mar 2023 15:21:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3158851#M113376</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-03-28T15:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: SUM measure for multiple partitions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3160301#M113465</link>
      <description>&lt;P&gt;Not as easy, unfortunately...&lt;BR /&gt;It shouldn't ignore slicer selection...&lt;BR /&gt;In following selection it should show 60, not 93:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 08:29:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3160301#M113465</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-29T08:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: SUM measure for multiple partitions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3160326#M113467</link>
      <description>&lt;P&gt;The below seems to work&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;m1 subCtgVal 1,2 = 
VAR ChosenCats = ALLSELECTED( 'MyTable'[SubCategory1], 'MyTable'[SubCategory2], 'MyTable'[SubCategory3])
VAR Result =
    CALCULATE(
        SUM(MyTable[Value]),
		ALLEXCEPT( 'MyTable', 'MyTable'[SubCategory1], 'MyTable'[SubCategory2]),
        ChosenCats,
        SUMMARIZE(
            MyTable,
            MyTable[SubCategory1], -- Partition1
            MyTable[SubCategory2]  -- Partition2
        )
    )
RETURN Result&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 Mar 2023 08:45:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3160326#M113467</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-03-29T08:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: SUM measure for multiple partitions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3160814#M113509</link>
      <description>&lt;P&gt;Works! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Just Instead of&lt;/P&gt;&lt;LI-CODE lang="php"&gt;VAR ChosenCats = ALLSELECTED( 'MyTable'[SubCategory1], 'MyTable'[SubCategory2], 'MyTable'[SubCategory3])&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;recommend to use&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;VAR ChosenCats = ALLSELECTED( MyTable )&lt;/LI-CODE&gt;&lt;P&gt;It looks like more generic solution&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 12:37:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3160814#M113509</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-29T12:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: SUM measure for multiple partitions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3165946#M113860</link>
      <description>&lt;P&gt;The ALLEXCEPT seems redundant here since we already have the SUMMARIZE putting the partition filtering back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about this simplified version?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;VAR ChosenCats = ALLSELECTED ( MyTable )
VAR Result =
    CALCULATE (
        SUM ( MyTable[Value] ),
        ChosenCats,
        SUMMARIZE (
            MyTable,
            MyTable[SubCategory1], -- Partition1
            MyTable[SubCategory2]  -- Partition2
        )
    )
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;&lt;STRONG&gt;Edit:&lt;/STRONG&gt; Hang on... This should be the same as the original measure. Let me dig in and see why that one isn't working as expected. Will update later.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Edit 2:&lt;/STRONG&gt; The above appears to work fine. I think the difference is that ALLSELCTED inside of CALCULATE means &lt;A href="https://www.sqlbi.com/articles/the-definitive-guide-to-allselected/" target="_blank"&gt;transforming a shadow filter context into an explicit filter context&lt;/A&gt; rather than being used as a more typical table filter when we pass it in as a variable.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 16:26:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-measure-for-multiple-partitions/m-p/3165946#M113860</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2023-03-31T16:26:15Z</dc:date>
    </item>
  </channel>
</rss>

