Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

UNDERSTANDING CALCULATE FUNCTION

Hi Team,   I have the dataset as below                                Product Table Color FruitName  Green apples Yellow bananas Orange oranges Sales table FruitName        ...
  • v-luwang-msft's avatar
    5 years ago

    Hi Anonymous ,

    When the second argument of CALCULATE is a boolean filter rather than a table of values, it is equivalent to FILTER(ALL(column), filter): that is: 

    CALCULATE(sumx('Sales table','Sales table'[Quantity]*'Sales table'[SaleAmt]),

    FILTER(ALL('Product Table'[Color]),'Product Table'[Color]="Yellow")).

     

     

     

    And CALCULATE does indeed override the filter context when evaluating its first argument; using the rows provided to its second argument as the new filter context. However; CALCULATE does not alter the filter context when evaluating its second argument, and so pre-existing filters remain unless they are explicitly removed.
     
     
     
     
    Best Regards
    Lucien