<?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: Is there sth wrong with summarize function? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/74777#M95</link>
    <description>Hi Alberto.&lt;BR /&gt;&lt;BR /&gt;First, let me apologize for attributing the article to Marco.&lt;BR /&gt;&lt;BR /&gt;The behavior you describe is indeed a feature. What I was referring to as a bug, is the fact that the result of the query changes depending on the order of the columns in the table, when the table was created. This buggy behavior cannot be seen in the simplified example you just provided, because it only has 2 columns.&lt;BR /&gt;&lt;BR /&gt;To clarify my point: Only the leftmost column will be added to the shaped set. Furthermore, which column is the leftmost one is set when the table is added to the model. Reordering columns will not modify the results afterwards.</description>
    <pubDate>Tue, 04 Oct 2016 11:13:26 GMT</pubDate>
    <dc:creator>LaurentCouartou</dc:creator>
    <dc:date>2016-10-04T11:13:26Z</dc:date>
    <item>
      <title>Is there sth wrong with summarize function?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/71276#M79</link>
      <description>&lt;P&gt;I Reproduce the scenario in&amp;nbsp;&lt;A href="http://www.sqlbi.com/articles/all-the-secrets-of-summarize/" target="_blank"&gt;http://www.sqlbi.com/articles/all-the-secrets-of-summarize/&lt;/A&gt;, but &amp;nbsp;the answer is different.&lt;/P&gt;&lt;P&gt;&lt;img&gt;﻿&lt;/img&gt;&lt;/P&gt;&lt;P&gt;anyone can explain it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;change the first product from bike to shirt, the answer is different:&lt;/P&gt;&lt;P&gt;&lt;img&gt;﻿&lt;/img&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 07:34:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/71276#M79</guid>
      <dc:creator>ryan-gao</dc:creator>
      <dc:date>2016-09-23T07:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is there sth wrong with summarize function?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/73213#M83</link>
      <description>&lt;P&gt;When Marco Russo wrote his article, the value returned (500) was:&lt;BR /&gt;&lt;BR /&gt;Total of Amount for all rows with&lt;BR /&gt;Product = "Bike" and Quantity = 1 and Amount = 100&lt;BR /&gt;or&lt;BR /&gt;Product = "Shirt" and Quantity = 2 and Amount = 200&lt;BR /&gt;&lt;BR /&gt;1200 is the total of Amount rows for all rows where Product = "Shirt".&lt;BR /&gt;&lt;BR /&gt;The implicit filter seems to ignore the columns Quantity and Price.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When Marco Russo wrote his article, the value returned (500) was:&lt;BR /&gt;&lt;BR /&gt;Total of Amount for all rows with&lt;BR /&gt;Product = "Bike" and Quantity = 1 and Amount = 100&lt;BR /&gt;or&lt;BR /&gt;Product = "Shirt" and Quantity = 2 and Amount = 200&lt;BR /&gt;&lt;BR /&gt;1200 is the total of Amount rows for all rows where Product = "Shirt".&lt;BR /&gt;&lt;BR /&gt;The implicit filter seems to ignore the columns Quantity and Price.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you use Excel 2016?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 12:26:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/73213#M83</guid>
      <dc:creator>LaurentCouartou</dc:creator>
      <dc:date>2016-09-29T12:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Is there sth wrong with summarize function?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/73473#M86</link>
      <description>&lt;P&gt;yes,Laurent&lt;SPAN class=""&gt;, I did it in excel2016 and also Power BI, the answer is equal.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Does &amp;nbsp;different version of the tool make &amp;nbsp;different answer?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2016 01:15:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/73473#M86</guid>
      <dc:creator>ryan-gao</dc:creator>
      <dc:date>2016-09-30T01:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Is there sth wrong with summarize function?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/73680#M88</link>
      <description>&lt;P&gt;Well, the Power Pivot engine in Excel 2016 is not the same as the one used by Excel 2013 (when Marco Russo wrote his article).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have made a few tests, and here are my conclusions: this is a &lt;STRONG&gt;bug&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The long version is the behaviour no longer works as Marco Russo explained in his article. There is still an implicit filter but only on the first column in the table (at the time of creation).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you create a new table with columns listed in this order: &lt;EM&gt;Quantity, Product, Color, Amount, &lt;/EM&gt;like this&lt;EM&gt;:&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P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t;Color allcolorsales&lt;/P&gt;&lt;P&gt;Red&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 500&lt;/P&gt;&lt;P&gt;Green 1300&lt;/P&gt;&lt;P&gt;Blue&amp;nbsp;&amp;nbsp;&amp;nbsp; 1300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that, according to my observations, what is relevant is the columns order &lt;EM&gt;when the table was created&lt;/EM&gt;. Re-ordering the columns afterwards does not seem to change the results of the query. This is, in my opinion, a bug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2016 12:29:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/73680#M88</guid>
      <dc:creator>LaurentCouartou</dc:creator>
      <dc:date>2016-09-30T12:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Is there sth wrong with summarize function?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/73713#M89</link>
      <description>&lt;P&gt;Thanks &amp;nbsp;for you &lt;A target="_blank"&gt;detailed&lt;/A&gt; &lt;A target="_blank"&gt;description&amp;nbsp;&lt;/A&gt;Laurent,I Totally agree with you.&lt;/P&gt;&lt;P&gt;Hope&amp;nbsp;@marcorusso can see this&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2016 13:44:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/73713#M89</guid>
      <dc:creator>ryan-gao</dc:creator>
      <dc:date>2016-09-30T13:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there sth wrong with summarize function?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/74527#M93</link>
      <description>&lt;P&gt;Hi Laurent,&lt;/P&gt;&lt;P&gt;I wish it was a bug, unfortunately it is only extremely hard to understand, starting by myself! It took me a while to find the correct answer :)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The behavior is indeed different in the 2016 version but, since I wrote that article, I learned a bit more about DAX, and we've been able to understand the topic of arbitrarily shaped sets. This lead me to define the problem in an easier way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In reality, the problem of SUMMARIZE is nothing but the creation of arbitrarily shaped sets that&amp;nbsp;are destroyed as a consequence of context transition. In fact, it is worth remembering that SUMMARIZE is the only function, AFAIK, that generates both a row context and a filter context. The row context is seldom used, still it is there. Thus, as soon as you call CALCULATE, you force context transition, and this is the source of the error (or... let us call it a "feature").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why is this relevant? You can see the effect with a simpler table. The following one is a variation of the one used in the post. Please note that I removed the numeric columns and - in the last line - I put a Bike instead of a Shirt (this is VERY important, otherwise the problem does not show up; the previous dataset was too simple). Please note that there is NO Blue Shirt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img&gt;﻿&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On this simpler model, you can run a variation of the original query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;EVALUATE
SUMMARIZE (
    Sales,
    Sales[Color],
    "Sales", COUNTROWS ( Sales ),
    "AllColorSales", 
    CALCULATE (
        COUNTROWS ( Sales ),  
        ALL ( Sales[Color] )
     ),
    "AllSales", 
    CALCULATE (
        COUNTROWS ( Sales ),  
        ALL ( Sales )
    )
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I replaced SUM with COUNTROWS, because now I have a simpler model. The result, as you might guess, is wrong:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img&gt;﻿&lt;/img&gt;&lt;/P&gt;&lt;P&gt;The last line, showing 4, is wrong. Why that? Because when you&amp;nbsp;are on the BLUE row the filter context contains ( BLUE, BIKE ) and it is transformed into (BIKE), which contains 4 rows. When you are on Green, on the other hand, the filter context contains ( GREEN, [ Bike || Shirt ] ) and, after context transition, it becomes [ Bike || Shirt ], showing the correct result of 7. Strictly speaking, (BLUE, BIKE) is not an arbitrarily shaped set, it is so because it is coming as a selection of SUMMARIZE that creates the relation (BLUE, BIKE). In fact, nowhere you selected BIKE, it went into the filter context because of the filter generated by SUMMARIZE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your theory of a bug is not correct. In fact, if you replace Color with Product in the previous query, you will obtain - still - an incorrect result, this time for the Shirt row. Here is the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;EVALUATE
SUMMARIZE (
    Sales,
    Sales[Product],
    "Sales", COUNTROWS ( Sales ),
    "AllProductSales", 
    CALCULATE (
        COUNTROWS ( Sales ),  
        ALL ( Sales[Product] )
     ),
    "AllSales", 
    CALCULATE (
        COUNTROWS ( Sales ),  
        ALL ( Sales )
    )
)&lt;/PRE&gt;&lt;P&gt;All this is not to say you were wrong, of course. It took me a while to find an easy dataset that shows the behavior of SUMMARIZE and, in doing that, I learned a bit more. In fact, in the previous post, I was using a much more complex dataset, mainly because I was not fully understanding it. I am extremely grateful that you pointed out the problems with the old blog post about SUMMARIZE, because you forced me to come back to a topic I heartily hate (SUMMARIZE) and understand it better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My hint - anyway - is always the same: avoid SUMMARIZE to compute anything. Use it to perform grouping by, but avoid adding columns in SUMMARIZE. It generates arbitrarily shaped sets during its partitioning of the table; and arbitrarily shaped sets are soooo hard to grasp when you use them with a CALCULATE that overrides some of their columns. I always go crazy trying to understand what is happening under the cover.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess, now, I will need to update that article... but, first, I should understand better what changed between 2016 and 2014, this requires some more time. I just wanted to write this short answer before digging more into these details.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 21:32:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/74527#M93</guid>
      <dc:creator>AlbertoFerrari</dc:creator>
      <dc:date>2016-10-03T21:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Is there sth wrong with summarize function?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/74777#M95</link>
      <description>Hi Alberto.&lt;BR /&gt;&lt;BR /&gt;First, let me apologize for attributing the article to Marco.&lt;BR /&gt;&lt;BR /&gt;The behavior you describe is indeed a feature. What I was referring to as a bug, is the fact that the result of the query changes depending on the order of the columns in the table, when the table was created. This buggy behavior cannot be seen in the simplified example you just provided, because it only has 2 columns.&lt;BR /&gt;&lt;BR /&gt;To clarify my point: Only the leftmost column will be added to the shaped set. Furthermore, which column is the leftmost one is set when the table is added to the model. Reordering columns will not modify the results afterwards.</description>
      <pubDate>Tue, 04 Oct 2016 11:13:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/74777#M95</guid>
      <dc:creator>LaurentCouartou</dc:creator>
      <dc:date>2016-10-04T11:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there sth wrong with summarize function?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/74804#M96</link>
      <description>&lt;P&gt;Here are the steps to reproduce the bug, in Power BI Desktop&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a new PBI file&lt;/P&gt;&lt;P&gt;Add a new query and call it &lt;EM&gt;Sales&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsrMTlXSUQpKTQGSTkqxOtFKwRmZRSU4xNyLUlPz4KJQzTBBR8JKnXJKU+EqMcRiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Product = _t, Color = _t, Model = _t]),
    #"Type modifié" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Color", type text}, {"Model", type text}})
in
    #"Type modifié"&lt;/PRE&gt;&lt;P&gt;Add a new query and call it &lt;EM&gt;Sales2&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;let
    Source = Sales,
    #"Colonnes triées" = Table.ReorderColumns(Source,{"Model", "Product", "Color"})
in #"Colonnes triées"&lt;/PRE&gt;&lt;P&gt;The second query only reorders the columns from the first one.&lt;/P&gt;&lt;P&gt;Now, back to the model, we should have two tables : &lt;EM&gt;Sales&lt;/EM&gt; and &lt;EM&gt;Sales2. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let us add a two calculated tables: &lt;EM&gt;TestSales&lt;/EM&gt; and &lt;EM&gt;TestSales2&lt;/EM&gt;.&lt;/P&gt;&lt;PRE&gt;TestSales = SUMMARIZE ( Sales,
    Sales[Color],
    "Sales", COUNTROWS( Sales ),
    "AllColorSales", 
    CALCULATE (
        COUNTROWS ( Sales ), 
        ALL ( Sales[Color] )
     ),
    "AllSales", 
    CALCULATE (
        COUNTROWS ( Sales ),  
        ALL ( Sales )
    )
)&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;TestSales2 = SUMMARIZE ( Sales2, Sales2[Color], "Sales2", COUNTROWS( Sales2 ), "AllColorSales2", CALCULATE ( COUNTROWS ( Sales2 ), ALL ( Sales2[Color] ) ), "AllSales2", CALCULATE ( COUNTROWS ( Sales2 ), ALL ( Sales2 ) ) )&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both calculated tables should return the same result. (left: &lt;EM&gt;TestSales&lt;/EM&gt;, right: &lt;EM&gt;TestSales2&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;img&gt;﻿&lt;/img&gt;&lt;img&gt;﻿&lt;/img&gt;&lt;/EM&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;jk&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;&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;</description>
      <pubDate>Tue, 04 Oct 2016 12:39:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-sth-wrong-with-summarize-function/m-p/74804#M96</guid>
      <dc:creator>LaurentCouartou</dc:creator>
      <dc:date>2016-10-04T12:39:57Z</dc:date>
    </item>
  </channel>
</rss>

