<?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: Use SUMMARIZE in measure calculations in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2560240#M72807</link>
    <description>&lt;P&gt;Thanks a lot. I was so busy that I couldn't check here. Will test your solution.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jun 2022 06:19:37 GMT</pubDate>
    <dc:creator>SajjadMousavi</dc:creator>
    <dc:date>2022-06-06T06:19:37Z</dc:date>
    <item>
      <title>Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2507952#M69501</link>
      <description>&lt;P&gt;Hi all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a calculated table as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CompanyMSSummarized = &lt;/SPAN&gt;&lt;SPAN&gt;SUMMARIZE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DistributionPerCompany&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;DistributionPerCompany[ProdType]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"Disrtribution"&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;DistributionPerCompany[Year]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;DistributionPerCompany[Company]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Qty"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DistributionPerCompany[RealQty]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This table summarizes another table which has many columns, from which only the above 3 are needed. Then I have added these calculated columns to CompanyMSSummarized:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CurrentPct = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;TotalQty&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized[Qty]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized&lt;/SPAN&gt;&lt;SPAN&gt;), (&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized[Year]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;EARLIER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized[Year]&lt;/SPAN&gt;&lt;SPAN&gt;))))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt; &lt;SPAN&gt;100&lt;/SPAN&gt;&lt;SPAN&gt; * &lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized[Qty]&lt;/SPAN&gt;&lt;SPAN&gt; / &lt;/SPAN&gt;&lt;SPAN&gt;TotalQty&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;PrevPct = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized[CurrentPct]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized&lt;/SPAN&gt;&lt;SPAN&gt;), (&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized[Company]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;EARLIER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized[Company]&lt;/SPAN&gt;&lt;SPAN&gt;)) &amp;amp;&amp;amp; (&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized[Year]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;EARLIER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CompanyMSSummarized[Year]&lt;/SPAN&gt;&lt;SPAN&gt;) - &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;)))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Now, I want to know if there is any way to re-write these columns as measures. I need this because measures have some formatting options which can be used in some visuals (such as KPIs), which are not available directly through those visuals. As these fields are not calculated very often (Once a month), using measures and in-memory calculations is not resource-intensive compared to calculated tables.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 11 May 2022 13:50:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2507952#M69501</guid>
      <dc:creator>SajjadMousavi</dc:creator>
      <dc:date>2022-05-11T13:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2508018#M69507</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195881" data-lia-user-login="SajjadMousavi" class="lia-mention lia-mention-user"&gt;SajjadMousavi&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Almost the same&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;CurrentPct =
VAR TotalQty =
    CALCULATE (
        SUM ( CompanyMSSummarized[Qty] ),
        FILTER (
            ALL ( CompanyMSSummarized ),
            CompanyMSSummarized[Year] = EARLIER ( CompanyMSSummarized[Year] )
        )
    )
RETURN
    100 * SUM ( CompanyMSSummarized[Qty] ) / TotalQty&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;PrevPct =
CALCULATE (
    SUM ( CompanyMSSummarized[CurrentPct] ),
    FILTER (
        ALL ( CompanyMSSummarized ),
        CompanyMSSummarized[Company] = EARLIER ( CompanyMSSummarized[Company] )
            &amp;amp;&amp;amp; CompanyMSSummarized[Year]
                = EARLIER ( CompanyMSSummarized[Year] ) - 1
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 11 May 2022 14:22:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2508018#M69507</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-05-11T14:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2509462#M69566</link>
      <description>&lt;P&gt;Thansk for your reply, but I'm looking for a way to skip creation of summarized table. In addition, you cannot use EARLIER function in a measure, as measres are not aware of row context.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 06:10:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2509462#M69566</guid>
      <dc:creator>SajjadMousavi</dc:creator>
      <dc:date>2022-05-12T06:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2509571#M69575</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195881" data-lia-user-login="SajjadMousavi" class="lia-mention lia-mention-user"&gt;SajjadMousavi&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;There is a row context created by FILTER. However, please clarify exactly what is required. I'm a little confused. Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 06:41:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2509571#M69575</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-05-12T06:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2514788#M69881</link>
      <description>&lt;P&gt;I just want to skip creation of&amp;nbsp;&lt;SPAN&gt;CompanyMSSummarized&amp;nbsp;table in data model (want to create it on-the-fly in some way) and do calculations. But when I summarize&amp;nbsp;DistributionPerCompany in a measure, I cannot use it in subsequent calculations (like the one you suggested) and Power BI gives this error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2022 04:06:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2514788#M69881</guid>
      <dc:creator>SajjadMousavi</dc:creator>
      <dc:date>2022-05-14T04:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2514792#M69882</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195881" data-lia-user-login="SajjadMousavi" class="lia-mention lia-mention-user"&gt;SajjadMousavi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please paste the so I can copy it and edit&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2022 04:14:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2514792#M69882</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-05-14T04:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2514947#M69893</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195881" data-lia-user-login="SajjadMousavi" class="lia-mention lia-mention-user"&gt;SajjadMousavi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. You absolutely can create a table on the fly, store it in a var and USE it subsequently. The only thing you're missing in your code is the correct references to the columns of the table. You cannot use the name of the variable to refer to them. For instance, you have to use SUMX and the original names of the columns. It's all about DATA LINEAGE.&lt;/P&gt;&lt;P&gt;2. You should never use SUMMARIZE to perform calculations in its body since SUMMARIZE is a very buggy (and complex) function (very dangerous in measures), and MS have refused fixing it a long time ago. Instead, you should use the hybrid SUMMARIZE/ADDCOLUMNS. Use SUMMARIZE only to get the distinct combination of rows from a (extended) table.&lt;/P&gt;&lt;P&gt;3. You should also never filter a full table (row 7 in your code). Always only the minimum number of columns that are needed.&lt;/P&gt;&lt;P&gt;4. EARLIER will not work in your code because to use it you have to have 2 different row contexts active at the same time. One is not enough. Incidentally, you should never use this function. Instead, you should use variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2022 09:44:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2514947#M69893</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-05-14T09:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2515709#M69954</link>
      <description>&lt;P&gt;Thanks a lot for details. About 3rd point you mentioned, this table has exactly minimum number of columns needed for calculations. Summarization is just to sum up data per year (as can be seend from code). Anyway, I will try to re-write the code using guidelines you gave. Hope I can do it.&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2022 12:48:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2515709#M69954</guid>
      <dc:creator>SajjadMousavi</dc:creator>
      <dc:date>2022-05-15T12:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2515711#M69956</link>
      <description>&lt;P&gt;Thanks in advance for your time:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CurrentPct = 
VAR CompanyMSS = SUMMARIZE(FILTER(DistributionPerCompany, DistributionPerCompany[ProdType] = "Distribution"), DistributionPerCompany[Year], DistributionPerCompany[Company], "Qty", SUM(DistributionPerCompany[RealQty]))
VAR TotalQty =
    CALCULATE (
        SUM ( CompanyMSS[Qty] ),
        FILTER (
            ALL ( CompanyMSS ),
            CompanyMSS[Year] = EARLIER ( CompanyMSS[Year] )
        )
    )
RETURN
    100 * SUM ( CompanyMSS[Qty] ) / TotalQty&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2022 12:53:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2515711#M69956</guid>
      <dc:creator>SajjadMousavi</dc:creator>
      <dc:date>2022-05-15T12:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2515729#M69960</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195881" data-lia-user-login="SajjadMousavi" class="lia-mention lia-mention-user"&gt;SajjadMousavi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what are you trying to achieve, but you may try&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;CurrentPct =
VAR CurrentYear =
    MAX ( DistributionPerCompany[Year] )
VAR CurrentCompany =
    MAX ( DistributionPerCompany[Company] )
VAR CompanyMSS =
    SUMMARIZE (
        FILTER (
            ALLSELECTED ( DistributionPerCompany ),
            DistributionPerCompany[ProdType] = "Distribution"
                &amp;amp;&amp;amp; DistributionPerCompany[Year] = CurrentYear
        ),
        DistributionPerCompany[Year],
        DistributionPerCompany[Company],
        "Qty", SUM ( DistributionPerCompany[RealQty] )
    )
VAR TotalQty =
    SUMX ( CompanyMSS, [Qty] )
VAR Qty =
    SUMX (
        FILTER ( CompanyMSS, DistributionPerCompany[Company] = CurrentCompany ),
        [Qty]
    )
RETURN
    100 * Qty / TotalQty&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 15 May 2022 13:22:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2515729#M69960</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-05-15T13:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Use SUMMARIZE in measure calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2560240#M72807</link>
      <description>&lt;P&gt;Thanks a lot. I was so busy that I couldn't check here. Will test your solution.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 06:19:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-SUMMARIZE-in-measure-calculations/m-p/2560240#M72807</guid>
      <dc:creator>SajjadMousavi</dc:creator>
      <dc:date>2022-06-06T06:19:37Z</dc:date>
    </item>
  </channel>
</rss>

