Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am not able to understand how nested CALCULATE statements overwrite the outer filter, in particular, one scenario where column overwrites the outer table filter: Consider the following visual and measures. Model : Contoso from DAX book
3) Nested CALC TABLE-FILTER FALSE =
Solved! Go to Solution.
First of all, presume that 'Product' table consists of other columns on top of 'Product'[Category], say 'Product'[ID].
Nested CALC TABLE-FILTER FALSE =
CALCULATE (
CALCULATE ( [Sales Amount], 'Product'[Category] = "Audio" ),
FILTER ( ALL ( 'Product' ), FALSE () )
)
Inner filter 'Product'[Category] = "Audio" overrides part of outer filter, ie 'Product'[Category] = BLANK(), but 'Product'[ID] = BLANK() DOES still exist, as well as any other filters on other columns of 'Product'.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@CNENFRNL consider the query start at line 40, even though we set the filter context as empty, dax is returning product keys using ALL. PRODUCT[CATEGORY] = "Audio" is translated into
FILTER(ALL( PRODUCT[CATEGORY]),PRODUCT[CATEGORY] = "Audio").
@tamerj1 see the queries starting at line 25 and line 33, when we set the filter context to empty VALUES is returning empty list but ALL is still returning all values in that column.
What you want to say? Or you mean to teach me something new?
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Not at all. I am sorry if you feel like that.
your point but 'Product'[ID] = BLANK() DOES still exist, as well as any other filters on other columns of 'Product'. You said Product[ID] = BLANK() still exist, I was trying to show you Product[ID] is not blank even thogh we set the filter on Product table is empty as you can see in the query at line 40.
(at line 40) You expect ALL() returns all the visible rows in the current filter context; but it's NOT the case for ALL(). It's now used as a top-level table expression, returning all the rows in a table, or all the values in a column, ignoring any filters that might have been applied.
Instead, you should use,
CALCULATETABLE (
VALUES ( 'Product'[ProductKey] ),
FILTER ( ALL ( 'Product' ), FALSE () )
)
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
First of all, presume that 'Product' table consists of other columns on top of 'Product'[Category], say 'Product'[ID].
Nested CALC TABLE-FILTER FALSE =
CALCULATE (
CALCULATE ( [Sales Amount], 'Product'[Category] = "Audio" ),
FILTER ( ALL ( 'Product' ), FALSE () )
)
Inner filter 'Product'[Category] = "Audio" overrides part of outer filter, ie 'Product'[Category] = BLANK(), but 'Product'[ID] = BLANK() DOES still exist, as well as any other filters on other columns of 'Product'.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Thanks for the help. CALCULATE is behaving as per your explanation.
Hi @hemanth4pbi
because in (4) both the inner and outer CALCULATE filters are filtering the same column. Therefore, the inner CALCULATE replaces the outer CALCULATE filter and the result is "Audio".
While number 3 filters all the products (another column with different granularity). This filter which is a empty table, is not replaced by the inner filter rather it is intersected with it and the interaction between the two filters is an empty table that returns blank.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
41 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
36 | |
33 | |
18 | |
18 |