Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The model has sales fact and product dimension. There is M:1 relationship on product_id column.

Assume there is a table visual with 2 columns: Product name and a measure.

Following are 2 sub-questions -

  1. Question regarding measure 1:

Measure 1 =

CALCULATE(

????????COUNT(Sales[SalesId]),

????????ALL('Product')

????)

Does ALL remove the filter from the product table from the sales table or does ALL return the unfiltered product table that leads to clearing of the filter context? Since table expansion happens only towards the 1 side, then how does un-filtering on product affect the sales calculation? Just trying to visualize the underlying logic of how the un-filtering works.

  1. Question regarding Measure2: Code:

    Measure2 = CALCULATE(

    ????????COUNT(Sales[SalesId]),

    ????????ALL('Product'[ProductName])

    ????)

ALL returns a single column (ProductName) table with all filters removed and there is no table expansion happening here so how does it logically work? Again I'm trying to visualize the underlying logic of how the un-filtering works.

question from:https://stackoverflow.com/questions/65862935/how-does-all-tablename-columnname-work-when-used-as-2nd-parameter-of-calculate

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

ALL used as a filter argument is filter modifier. It removes the filter on its argument.

When the argument is a table, it removes the filter over the entire expanded table (the table specified as argument). Whent the argument is one or more columns, it removes the filters over the specified columns.

Filter removals happen during the fourth step in the CALCULATE execution, after the context transition and before the expression evaluation

The explanation of the CALCULATE execution step can be found in the DAX Guide

In the Measure 1, all filters are removed from the 'Product' table. In the Measure 2, only the filter existing over 'Product'[Name] is removed

In recent DAX verisions, when used as a filter modifier, ALL can be replaced by REMOVEFILTERS


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...