Forum Discussion

Strom's avatar
Strom
Frequent Visitor
4 years ago
Solved

Evaluation context - mixed filter and row context

Hi, I have a question about how exactly works the evaluation context in example below. There is a simple model with one fact table Sales without corresponding dimensional tables.    Now I tr...
  • bcdobbs's avatar
    4 years ago

    Really great question. I've had to go back to page 316 onwards of "The Definitive Guide to DAX" to be sure.

     

    Key starting point is that Context Transition happens before further filters in CALCULATE and combined by Overwrite.

    In Point 2 {Product:”B”, Price:200} gets added into filter context. The further filter then results in [{Product:”B”, Price:200},{Product:”C”, Price:300}].Here DAX overwrites the existing filter resulting in [{Product:”B”, Price:200},{Product:”C”, Price:300}]


    In Point 5. I found much harder to get straight in my head! You're right that in the FILTER Sales[Price] is evaluated in the context on the original row and results in {A, B, C}. This still overwrites the existing filter coming from context transition but only in the Product Column. You're left with Product IN {A, B, C} AND the price that has come from the current row. For the second row {A, B, C} AND 200 results {B, 200}.

     

    Have a read of Understanding Context Transition - SQLBI
    Can also highly recommend "Advanced Evaluation Context" in The Definitive Guide to DAX.