<?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: Simplifying a SUMMARIZECOLUMNS with FILTERS EVALUATE query in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315756#M171372</link>
    <description>&lt;P&gt;Thank you! That works great! Thank you also for inlcuding the comments with the sections. Its not always easy to see where the pieces fit in from the official documentation. I appreciate your help!&lt;/P&gt;</description>
    <pubDate>Thu, 05 Dec 2024 19:42:47 GMT</pubDate>
    <dc:creator>mbahonen</dc:creator>
    <dc:date>2024-12-05T19:42:47Z</dc:date>
    <item>
      <title>Simplifying a SUMMARIZECOLUMNS with FILTERS EVALUATE query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315634#M171362</link>
      <description>&lt;P&gt;I'm trying to simplify a DAX Query formula and hoping someone can help me. I'm still somewhat new to DAX Queries to extract data from my model and am not always sure of the syntax. I created the Sample query below to illustrate what I have created. This works and does what I want it to do, which is to give me a total value for all dates (within the defined date range) for an ID (there are many, so this is my high level group). I just want one total though and don't want to list rows of records by the date or other dimensions. As I said, the below formula seems to be doing what I want, but I have to duplicate the FILTER values in both the SUMMARIZECOLUMNS portion AND in the ADDCOLUMNS portion for my SUM value. Is there any way to simplify this formula so I only need to apply the filters one time?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EVALUATE
ADDCOLUMNS (
    SUMMARIZECOLUMNS (
        'FactTable'[ID],
        FILTER (
                'FactTable',
                'FactTable'[ID] IN { "000012345678" }
                    &amp;amp;&amp;amp; 'FactTable'[Date] &amp;gt;= DATE ( 2024, 6, 30 )
                    &amp;amp;&amp;amp; 'FactTable'[Date] &amp;lt;= DATE ( 2024, 11, 30 )
                    &amp;amp;&amp;amp; 'FactTable'[OtherDimension] = "True"
        )
    ),
    "TotalToSum",
        CALCULATE (
            SUM ( 'FactTable'[TotalToSum] ),
            FILTER (
                'FactTable',
                'FactTable'[ID] IN { "000012345678" }
                    &amp;amp;&amp;amp; 'FactTable'[Date] &amp;gt;= DATE ( 2024, 6, 30 )
                    &amp;amp;&amp;amp; 'FactTable'[Date] &amp;lt;= DATE ( 2024, 11, 30 )
                    &amp;amp;&amp;amp; 'FactTable'[OtherDimension] = "True"
            )
        )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ETA: I just realized this formula doesn't do exactly as I want either. When I remove the ID filter, it then lists all the IDs with the same total rather than grouping the total by the ID which is what I'm trying to do.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 17:23:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315634#M171362</guid>
      <dc:creator>mbahonen</dc:creator>
      <dc:date>2024-12-05T17:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Simplifying a SUMMARIZECOLUMNS with FILTERS EVALUATE query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315681#M171365</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="391980" data-lia-user-login="mbahonen" class="lia-mention lia-mention-user"&gt;mbahonen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would recommend something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;EVALUATE
VAR Filter_ID =
    TREATAS ( { "000012345678" }, 'FactTable'[ID] )
VAR Filter_Date =
    DATESBETWEEN ( 'FactTable'[Date], DATE ( 2024, 6, 30 ), DATE ( 2024, 11, 30 ) )
VAR Filter_OtherDimension =
    TREATAS ( { "True" }, 'FactTable'[OtherDimension] )
RETURN
    SUMMARIZECOLUMNS (
        -- Groupby columns
        'FactTable'[ID],
        -- Filters
        Filter_ID,
        Filter_Date,
        Filter_OtherDimension,
        -- Additional columns
        "TotalToSum", SUM ( 'FactTable'[TotalToSum] )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SUMMARIZECOLUMNS itself can add columns computed in the filter context of the Groupby columns, so there is no need to wrap SUMMARIZECOLUMNS in ADDCOLUMNS in this case.&lt;/LI&gt;
&lt;LI&gt;Also, for clarity, I suggest creating variables for the filters.&lt;/LI&gt;
&lt;LI&gt;It's generally best to filter columns rather than tables, which is why I suggest splitting the filters by column. See&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/filter-columns-not-tables-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/filter-columns-not-tables-in-dax/&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Does the above query work as intended?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suggested reading:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/introducing-summarizecolumns/" target="_blank" rel="noopener"&gt;https://www.sqlbi.com/articles/introducing-summarizecolumns/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://dax.guide/summarizecolumns/" target="_blank" rel="noopener"&gt;https://dax.guide/summarizecolumns/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 18:17:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315681#M171365</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2024-12-05T18:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Simplifying a SUMMARIZECOLUMNS with FILTERS EVALUATE query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315756#M171372</link>
      <description>&lt;P&gt;Thank you! That works great! Thank you also for inlcuding the comments with the sections. Its not always easy to see where the pieces fit in from the official documentation. I appreciate your help!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 19:42:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315756#M171372</guid>
      <dc:creator>mbahonen</dc:creator>
      <dc:date>2024-12-05T19:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: Simplifying a SUMMARIZECOLUMNS with FILTERS EVALUATE query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315837#M171379</link>
      <description>&lt;P&gt;So one question I have is this... I used the ADDCOLUMNS function in my original version on the advisement of Marco from SQLBI via this article: &lt;A href="https://www.sqlbi.com/articles/all-the-secrets-of-summarize/" target="_blank"&gt;https://www.sqlbi.com/articles/all-the-secrets-of-summarize/ &lt;/A&gt;&lt;/P&gt;&lt;P&gt;Do you have any concerns with your version without using it?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 21:37:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315837#M171379</guid>
      <dc:creator>mbahonen</dc:creator>
      <dc:date>2024-12-05T21:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Simplifying a SUMMARIZECOLUMNS with FILTERS EVALUATE query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315879#M171380</link>
      <description>&lt;P&gt;No concerns &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The SUMMARIZECOLUMNS function is designed and optimized to handle computed columns like this. I would consider it a standard summarization function in any DAX query. Indeed, Power BI visuals generate DAX queries with this kind of syntax.&lt;/P&gt;
&lt;P&gt;Most examples on &lt;A href="https://dax.guide/" target="_blank" rel="noopener"&gt;https://dax.guide/&lt;/A&gt;&amp;nbsp;use a similar pattern to combine grouping columns and computed columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, until recently, SUMMARIZECOLUMNS couldn't be used reliably within ADDCOLUMNS among other scenarios.&lt;/P&gt;
&lt;P&gt;(Some discusson &lt;A href="https://learn.microsoft.com/en-us/dax/summarizecolumns-function-dax#contextual-summarizecolumns" target="_blank" rel="noopener"&gt;here&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the older function SUMMARIZE, ADDCOLUMNS is best practice due to some quirks mentioned in the article you linked to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 22:17:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315879#M171380</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2024-12-05T22:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Simplifying a SUMMARIZECOLUMNS with FILTERS EVALUATE query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315913#M171383</link>
      <description>&lt;P&gt;Thanks again for that extra detail! And for what its worth, so far all my versions of the adapted query have worked as I am expecting!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 22:53:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Simplifying-a-SUMMARIZECOLUMNS-with-FILTERS-EVALUATE-query/m-p/4315913#M171383</guid>
      <dc:creator>mbahonen</dc:creator>
      <dc:date>2024-12-05T22:53:46Z</dc:date>
    </item>
  </channel>
</rss>

