<?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 Measure: sumx with summarize in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-sumx-with-summarize/m-p/799618#M4802</link>
    <description>&lt;P&gt;I&amp;nbsp; have a table with following fields&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&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&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to calculate is the additional online sales in case the shop would sell the same % online per product as all shops together. I was able to generate a summarized table that calculates the "additional online sales"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SummarizedTabel =
ADDCOLUMNS (
    ADDCOLUMNS (
        ADDCOLUMNS (
            SUMMARIZE (
                Sales;
                Sales[Product];
                Sales[Region];
                Sales[Sold by];
                "Sales"; SUM ( Sales[Sales] );
                "Sales Online"; CALCULATE (
                    SUM ( Sales[Sales] );
                    ALLSELECTED ( Sales[Sold by] );
                    Sales[Sold by] = "Online"
                );
                "Sales Store"; CALCULATE (
                    SUM ( Sales[Sales] );
                    ALLSELECTED ( Sales[Sold by] );
                    Sales[Sold by] = "Store"
                );
                "Total shops Online"; CALCULATE (
                    SUM ( Sales[Sales] );
                    ALLSELECTED ( Sales[Sold by]; Sales[Region] );
                    Sales[Sold by] = "Online"
                );
                "Total shops store"; CALCULATE (
                    SUM ( Sales[Sales] );
                    ALLSELECTED ( Sales[Sold by]; Sales[Region] );
                    Sales[Sold by] = "Store"
                )
            );
            "Total shops online vs total"; [Total shops Online] / ( [Total shops Online] + [Total shops store] );
            "Selected shop online vs total"; [Sales Online] / ( [Sales Online] + [Sales Store] )
        );
        "diff total shops vs selected shop"; [Total shops online vs total] - [Selected shop online vs total]
    );
    "additional sales online"; IF (
        [diff total shops vs selected shop] &amp;lt; 0;
        0;
        [Sales] * [diff total shops vs selected shop]
    )
)&lt;/PRE&gt;&lt;P&gt;But as the original data has more then 1 million rows and I need to apply quite a lot of filters I could like to include the calculation of additional online sales in a measure so that all the report filters get applied (filters based on linked tables). I tried to include the code above in a measure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Addiontional sales =
SUMX (
    ADDCOLUMNS (
        ADDCOLUMNS (
            ADDCOLUMNS (
                SUMMARIZE (
                    Sales;
                    Sales[Product];
                    Sales[Region];
                    Sales[Sold by];
                    "Sales"; SUM ( Sales[Sales] );
                    "Sales Online"; CALCULATE (
                        SUM ( Sales[Sales] );
                        ALLSELECTED ( Sales[Sold by] );
                        Sales[Sold by] = "Online"
                    );
                    "Sales Store"; CALCULATE (
                        SUM ( Sales[Sales] );
                        ALLSELECTED ( Sales[Sold by] );
                        Sales[Sold by] = "Store"
                    );
                    "Total shops Online"; CALCULATE (
                        SUM ( Sales[Sales] );
                        ALLSELECTED ( Sales[Sold by]; Sales[Region] );
                        Sales[Sold by] = "Online"
                    );
                    "Total shops store"; CALCULATE (
                        SUM ( Sales[Sales] );
                        ALLSELECTED ( Sales[Sold by]; Sales[Region] );
                        Sales[Sold by] = "Store"
                    )
                );
                "Total shops online vs total"; [Total shops Online] / ( [Total shops Online] + [Total shops store] );
                "Selected shop online vs total"; [Sales Online] / ( [Sales Online] + [Sales Store] )
            );
            "diff total shops vs selected shop"; [Total shops online vs total] - [Selected shop online vs total]
        );
        "additional sales online"; IF (
            [diff total shops vs selected shop] &amp;lt; 0;
            0;
            [Sales] * [diff total shops vs selected shop]
        )
    );
    [additional sales online]
)&lt;/PRE&gt;&lt;P&gt;But when I look at the results it is not what I want to see. The total is correct but I am not able to see the additional sales per product en per region.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&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&gt;&amp;nbsp;&lt;/P&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&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I solve this? Is there another way to get this solved instead of using summarize?&lt;/P&gt;&lt;P&gt;I am using Power BI for just a few weeks, so I would be surprised if there is a much easier way to calculate the additional online sales.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help on this one...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Brenda&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2019 13:28:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-09-23T13:28:03Z</dc:date>
    <item>
      <title>Measure: sumx with summarize</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-sumx-with-summarize/m-p/799618#M4802</link>
      <description>&lt;P&gt;I&amp;nbsp; have a table with following fields&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&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&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to calculate is the additional online sales in case the shop would sell the same % online per product as all shops together. I was able to generate a summarized table that calculates the "additional online sales"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SummarizedTabel =
ADDCOLUMNS (
    ADDCOLUMNS (
        ADDCOLUMNS (
            SUMMARIZE (
                Sales;
                Sales[Product];
                Sales[Region];
                Sales[Sold by];
                "Sales"; SUM ( Sales[Sales] );
                "Sales Online"; CALCULATE (
                    SUM ( Sales[Sales] );
                    ALLSELECTED ( Sales[Sold by] );
                    Sales[Sold by] = "Online"
                );
                "Sales Store"; CALCULATE (
                    SUM ( Sales[Sales] );
                    ALLSELECTED ( Sales[Sold by] );
                    Sales[Sold by] = "Store"
                );
                "Total shops Online"; CALCULATE (
                    SUM ( Sales[Sales] );
                    ALLSELECTED ( Sales[Sold by]; Sales[Region] );
                    Sales[Sold by] = "Online"
                );
                "Total shops store"; CALCULATE (
                    SUM ( Sales[Sales] );
                    ALLSELECTED ( Sales[Sold by]; Sales[Region] );
                    Sales[Sold by] = "Store"
                )
            );
            "Total shops online vs total"; [Total shops Online] / ( [Total shops Online] + [Total shops store] );
            "Selected shop online vs total"; [Sales Online] / ( [Sales Online] + [Sales Store] )
        );
        "diff total shops vs selected shop"; [Total shops online vs total] - [Selected shop online vs total]
    );
    "additional sales online"; IF (
        [diff total shops vs selected shop] &amp;lt; 0;
        0;
        [Sales] * [diff total shops vs selected shop]
    )
)&lt;/PRE&gt;&lt;P&gt;But as the original data has more then 1 million rows and I need to apply quite a lot of filters I could like to include the calculation of additional online sales in a measure so that all the report filters get applied (filters based on linked tables). I tried to include the code above in a measure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Addiontional sales =
SUMX (
    ADDCOLUMNS (
        ADDCOLUMNS (
            ADDCOLUMNS (
                SUMMARIZE (
                    Sales;
                    Sales[Product];
                    Sales[Region];
                    Sales[Sold by];
                    "Sales"; SUM ( Sales[Sales] );
                    "Sales Online"; CALCULATE (
                        SUM ( Sales[Sales] );
                        ALLSELECTED ( Sales[Sold by] );
                        Sales[Sold by] = "Online"
                    );
                    "Sales Store"; CALCULATE (
                        SUM ( Sales[Sales] );
                        ALLSELECTED ( Sales[Sold by] );
                        Sales[Sold by] = "Store"
                    );
                    "Total shops Online"; CALCULATE (
                        SUM ( Sales[Sales] );
                        ALLSELECTED ( Sales[Sold by]; Sales[Region] );
                        Sales[Sold by] = "Online"
                    );
                    "Total shops store"; CALCULATE (
                        SUM ( Sales[Sales] );
                        ALLSELECTED ( Sales[Sold by]; Sales[Region] );
                        Sales[Sold by] = "Store"
                    )
                );
                "Total shops online vs total"; [Total shops Online] / ( [Total shops Online] + [Total shops store] );
                "Selected shop online vs total"; [Sales Online] / ( [Sales Online] + [Sales Store] )
            );
            "diff total shops vs selected shop"; [Total shops online vs total] - [Selected shop online vs total]
        );
        "additional sales online"; IF (
            [diff total shops vs selected shop] &amp;lt; 0;
            0;
            [Sales] * [diff total shops vs selected shop]
        )
    );
    [additional sales online]
)&lt;/PRE&gt;&lt;P&gt;But when I look at the results it is not what I want to see. The total is correct but I am not able to see the additional sales per product en per region.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&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&gt;&amp;nbsp;&lt;/P&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&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I solve this? Is there another way to get this solved instead of using summarize?&lt;/P&gt;&lt;P&gt;I am using Power BI for just a few weeks, so I would be surprised if there is a much easier way to calculate the additional online sales.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help on this one...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Brenda&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 13:28:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-sumx-with-summarize/m-p/799618#M4802</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-23T13:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Measure: sumx with summarize</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-sumx-with-summarize/m-p/800646#M4828</link>
      <description>GOOD PIECE OF ADVICE: Do not use SUMMARIZE for obtaining figures. Use this function ONLY for getting the combinations of values against which you want to calculate numbers. Instead, use the combination of SUMMARIZE/ADDCOLUMNS.&lt;BR /&gt;&lt;BR /&gt;SUMMARIZE is a very complex function that has many bugs into the bargain. Complex in this context means it's very often doing something different from what you think it should.&lt;BR /&gt;&lt;BR /&gt;If you want to know why you shouldn't do that please refer to the articles on SUMMARIZE at &lt;A href="http://www.sqlbi.com" target="_blank"&gt;www.sqlbi.com&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D.</description>
      <pubDate>Tue, 24 Sep 2019 10:57:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-sumx-with-summarize/m-p/800646#M4828</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-24T10:57:32Z</dc:date>
    </item>
  </channel>
</rss>

