Quantcast
Channel: SQLBI
Viewing all articles
Browse latest Browse all 434

Unexpected side effects of table filters in #dax

$
0
0

One of the side effects that you might not expect from a table filter in a CALCULATE statement is the removal of an existing filter. In reality, this is a condition that happens when you write an explicit CALCULATE in a row context, because the table filter overrides the context transition in case you filter the same table that generated the context transition.

In practice, the following query return the same value for every color, ignoring the context transition for Product[Color]:

ADDCOLUMNS (
    VALUES ( Product[Color] ),
    "Sales", CALCULATE(
        [Average Sales Amount],
        FILTER ( Sales, Sales[Quantity] > 3 )
    )
)

If you know the context transition and you think this is strange, Alberto wrote a good article explaining this particular situation: read Context Transition and Expanded Tables on SQLBI web site!


Viewing all articles
Browse latest Browse all 434

Trending Articles