Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
AlB
Super User
Super User

DAX: Who wants a challenge with SUMMARIZE?

As background, this question is related to the issues with SUMMARIZE explained in this SQLBI article. There it is explained that because of the particular way SUMMARIZE applies filters when creating columns, "strange" behaviours can come up.

 

I am working with the Contoso DB and the data model from the Definitive guide to DAX. Available here.   We have the below query where we want to show the number of products by color. Product has a many-to-1 relationship with 'Product Subcategory' and 'Product Subcategory' a many-to-1 with 'Product Category'.

 

Table1=
SUMMARIZE (
'Product',
'Product'[Color],
"NumOfProducts", CALCULATE ( [NumOfProducts], ALL ( 'Product'[Color] ) )
)

Since 'Product' has not only one but several columns with no duplicates (like ProductKey), I would expect the query to work. It doesn't. Interestingly enough, the results we get in the column NumOfProducts are: for the row with colorX, the number of products of any color within the categories determined by ColorX. For instance, for color Azure, all Azure products are from category "Cameras and Recorders". What the row for Azure shows in NumOfProducts is 372, the number of products of any color within the category "Cameras and recorders".

 

The expanded Product table must be playing a role here. The source table in SUMMARIZE is partitioned in segments by color as explained in the article and when we remove the color filter, we still have filters on, for instance, the categories. Ok. But we also have the filter on ProductKey (no duplicates) and even the Subcategory, which is more restrictive than the Category. The following does work. Anyone any idea what is actually going on? Thanks

 

Table2=
SUMMARIZE (
'Product',
'Product'[Color],
"NumOfProducts", CALCULATE (
[NumOfProducts],
ALL ( 'Product'[Color] ),
ALL ( 'Product Subcategory' ),
ALL ( 'Product Category' )
)
)

 

1 ACCEPTED SOLUTION

Thanks @TomMartens

I'll have a look.

In any case, I've had a reply on the subject from the folks at SQLBI. They claim SUMMARIZE with expressions/measures has been so problematic that they've just stopped using it and they hope it is soon deprecated. It works fine for grouping though.  

View solution in original post

6 REPLIES 6
TomMartens
Super User
Super User

Hey, 

 

please provide the definition of the measure [NumOfProducts} that you are using, as it is not used in the article and not in the companion pbix to the book, at least not in mine.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens,

 

Sales[NumOfProducts] =
        DISTINCTCOUNT ( 'Product'[Product Name] )

Thanks

Hey,

 

give this epic blog post by Jeffrey Wang (the product owner of the DAX enging @ MSFT) a try:

http://mdxdax.blogspot.com/2011/03/logic-behind-magic-of-dax-cross-table.html

 

I think it's difficult to reconstruct what the quoted article describes, as it is no longer valid, due to behavior change in the underlying components, as mentioned in the top most [Edit] to the article.

 

Nevertheless, everything that can be said about stuff, has been said in the article.

 

After you have read the above article, I recommend these one:

  1. http://mdxdax.blogspot.com/2011/01/dax-time-intelligence-functions.html
  2. https://pbidax.wordpress.com/2016/05/22/simple-filter-in-dax-measures/

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks @TomMartens

I'll have a look.

In any case, I've had a reply on the subject from the folks at SQLBI. They claim SUMMARIZE with expressions/measures has been so problematic that they've just stopped using it and they hope it is soon deprecated. It works fine for grouping though.  

v-chuncz-msft
Community Support
Community Support

@AlB,

 

Try to understand the context of the Expression in SUMMARIZE.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft

I've done that but to no avail.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.