Forum Discussion

jdusek92's avatar
jdusek92
Icon for Advocate III rankAdvocate III
7 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 filter is applied to the page, the matrix still shows all the rows (with blank value fields for rows that should be filtered out). Visual level filter WORKS fine

 

When I remove measures from value fields, the page filtering starts working and Matrix rows are filtered correctly

 

What am I missing? Why does measure fiddle with filtering and how to fix it?

 

Thank you

 

 

 

 

 

 

  • 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.

     

1 Reply

  • kentyler's avatar
    kentyler
    Icon for Solution Sage rankSolution Sage

    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.