Forum Discussion

jdusek92's avatar
jdusek92
Advocate III
6 years ago
Solved

Matrix with measure values not filtering

Hello,  this is probably a beginners question. I have a matrix with some value fields - of which some are measures (some basic Calculate(Sum()) stuff). It works fine.   But when a page level filt...
  • kentyler's avatar
    6 years ago

    this is a tricky one

    from the docs

    Remarks

    If the data has been filtered, the CALCULATE function changes the context in which the data is filtered, and evaluates the expression in the new context that you specify. For each column used in a filter argument, any existing filters on that column are removed, and the filter used in the filter argument is applied instead.

     

    so you either have to refilter inside calculate or use something like KEEPFILTERS

    again from the docs

    The KEEPFILTERS function allows you to modify this behavior. When you use KEEPFILTERS, any existing filters in the current context are compared with the columns in the filter arguments, and the intersection of those arguments is used as the context for evaluating the expression. The net effect over any one column is that both sets of arguments apply: both the filter arguments used in CALCULATE and the filters in the arguments of the KEEPFILTER function. In other words, whereas CALCULATE filters replace the current context, KEEPFILTERS adds filters to the current context.