<?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: SUMX over multiple columns - Is this the optimal syntax? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2269541#M55186</link>
    <description>&lt;P&gt;Ultimately, I'm designing a measure here. I don't want to add a new table to the data model.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jan 2022 14:05:29 GMT</pubDate>
    <dc:creator>mattcarter865</dc:creator>
    <dc:date>2022-01-06T14:05:29Z</dc:date>
    <item>
      <title>SUMX over multiple columns - Is this the optimal syntax?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2268627#M55126</link>
      <description>&lt;P&gt;I'm trying to design a measure that sums a constant value for each distinct set of values involving multiple columns in my data model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is similar to the formula I ended up with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'Sales'[Earned Promotions] =&lt;BR /&gt;SUMX (&lt;BR /&gt;  SUMMARIZE (&lt;BR /&gt;    FILTER ( Sales, Sales[Quantity] = 1 ),&lt;BR /&gt;    Promotion[Promotion Code],&lt;BR /&gt;    'Date'[Calendar Year Month]&lt;BR /&gt;  ),&lt;BR /&gt;  ( 1 / 12 )&lt;BR /&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running sample here&lt;/P&gt;&lt;P&gt;&lt;A href="https://dax.do/tM4fkfNewjz98s/" target="_blank"&gt;https://dax.do/tM4fkfNewjz98s/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The intent is to add 1/12th for each month a promotion is going on but only for sales involving a single quantity. (I work in insurance. This is a contrived example meant to mimic calculation of earned policy years.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My formula works, but I am unsure it is the optimal way to structure it. I tried swapping the order so that SUMMARIZE was called from within FILTER, but performance seemed about the same.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still new to DAX and trying to navigate the overly numerous ways to manipulate tables.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 04:10:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2268627#M55126</guid>
      <dc:creator>mattcarter865</dc:creator>
      <dc:date>2022-01-06T04:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: SUMX over multiple columns - Is this the optimal syntax?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2268685#M55128</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="301898" data-lia-user-login="mattcarter865" class="lia-mention lia-mention-user"&gt;mattcarter865&lt;/a&gt; , What filter is ensuring distinct Promotion Code and month combination?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I usually prefer to create a table in such a case&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;addcolumns (&lt;BR /&gt;SUMMARIZE (&lt;BR /&gt;FILTER ( Sales, Sales[Quantity] = 1 ),&lt;BR /&gt;Promotion[Promotion Code],&lt;BR /&gt;'Date'[Calendar Month end date] //&amp;nbsp; using month end date &lt;BR /&gt;),"Value", ( 1 / 12 ) )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and join it in the data model with a date table Promotion table .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you code seem fine to me&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 05:31:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2268685#M55128</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-01-06T05:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: SUMX over multiple columns - Is this the optimal syntax?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2269541#M55186</link>
      <description>&lt;P&gt;Ultimately, I'm designing a measure here. I don't want to add a new table to the data model.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 14:05:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2269541#M55186</guid>
      <dc:creator>mattcarter865</dc:creator>
      <dc:date>2022-01-06T14:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: SUMX over multiple columns - Is this the optimal syntax?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2274693#M55471</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="301898" data-lia-user-login="mattcarter865" class="lia-mention lia-mention-user"&gt;mattcarter865&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the result is what you want, there is no need to modify anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually, First add a 'value' column in summarize function then accumulate it, which is more in line with the writing specification.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
SUMX ( SUMMARIZE ( 'Table', [Column1], [Column2], "Value", 1 / 12 ), [Value] )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;I don't understand why you want to accumulate 1/12.&amp;nbsp;If you can share some sample data and your expected result in the visual, maybe I can give you a different solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="" data-block="true" data-editor="bn1so" data-offset-key="6hahu06b-0-0"&gt;
&lt;DIV class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="6hahu06b-0-0"&gt;&lt;SPAN data-offset-key="6hahu06b-0-0"&gt;Best Regards,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="" data-block="true" data-editor="bn1so" data-offset-key="dnr5l5ef-0-0"&gt;
&lt;DIV class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="dnr5l5ef-0-0"&gt;&lt;SPAN data-offset-key="dnr5l5ef-0-0"&gt;Community Support Team _ Janey&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="" data-block="true" data-editor="bn1so" data-offset-key="at626868-0-0"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 10 Jan 2022 06:44:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2274693#M55471</guid>
      <dc:creator>v-janeyg-msft</dc:creator>
      <dc:date>2022-01-10T06:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: SUMX over multiple columns - Is this the optimal syntax?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2275375#M55522</link>
      <description>&lt;P&gt;Thanks. The 1/12 is not the important part. I just need to accumulate a constant value (other than 1).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My original formula does work. My question is more about understanding if I'm doing it the "preferred" way. When looking through options for DAX I find it confusing to determine if I should use SUMMARIZE vs SUMMARIZECOLUMNS vs SUMMARIZE/ADDCOLUMNS vs CALCULATETABLE, etc. Plus in my particular example I need to filter the fact table on a particular value (as I showed in my example).&amp;nbsp;&lt;A href="https://dax.do/tM4fkfNewjz98s/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://dax.do/tM4fkfNewjz98s/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 13:01:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2275375#M55522</guid>
      <dc:creator>mattcarter865</dc:creator>
      <dc:date>2022-01-10T13:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: SUMX over multiple columns - Is this the optimal syntax?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2277100#M55605</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="301898" data-lia-user-login="mattcarter865" class="lia-mention lia-mention-user"&gt;mattcarter865&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I checked your sample data&amp;nbsp;and found no problem.&amp;nbsp;You built the eligible virtual table with &lt;SPAN&gt;SUMMARIZE&lt;/SPAN&gt;() function and then used SUMMARIZECOLUMNS() function to return the table with the fields you need. And you don't need to &lt;SPAN&gt;ADDCOLUMNS(It will preserve the context of the original table) and CALCULATETABLE(You mainly rely on relationships rather than specific conditions to filter in addition to the original table) functions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="" data-block="true" data-editor="bn1so" data-offset-key="6hahu06b-0-0"&gt;
&lt;DIV class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="6hahu06b-0-0"&gt;
&lt;DIV class="" data-block="true" data-editor="rjnu" data-offset-key="7evmi671-0-0"&gt;
&lt;DIV class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="7evmi671-0-0"&gt;&lt;STRONG&gt;If this post helps, please consider Accept it as the solution to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="" data-block="true" data-editor="rjnu" data-offset-key="1goep27d-0-0"&gt;
&lt;DIV class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="1goep27d-0-0"&gt;&lt;STRONG&gt;If not, please feel free to ask me.&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="" data-block="true" data-editor="rjnu" data-offset-key="gner03cd-0-0"&gt;
&lt;DIV class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="gner03cd-0-0"&gt;&lt;SPAN data-offset-key="gner03cd-0-0"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="" data-block="true" data-editor="rjnu" data-offset-key="10po32a8-0-0"&gt;
&lt;DIV class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="10po32a8-0-0"&gt;&lt;SPAN data-offset-key="10po32a8-0-0"&gt;Best Regards,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="" data-block="true" data-editor="rjnu" data-offset-key="2dt16743-0-0"&gt;
&lt;DIV class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="2dt16743-0-0"&gt;&lt;SPAN data-offset-key="2dt16743-0-0"&gt;Community Support Team _ Janey&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 09:15:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMX-over-multiple-columns-Is-this-the-optimal-syntax/m-p/2277100#M55605</guid>
      <dc:creator>v-janeyg-msft</dc:creator>
      <dc:date>2022-01-11T09:15:07Z</dc:date>
    </item>
  </channel>
</rss>

