Forum Discussion

juninhofaquino's avatar
juninhofaquino
New Member
2 months ago
Solved

Filter Matrix by dynamic measure without recalculating values (Hierarchy Matrix - Power BI)

Hi everyone, I'm facing a scenario that I couldn't solve after trying several DAX approaches, and I'd like to know if there is any supported solution for this. Scenario I have a Matrix visu...
  • Ritaf1983's avatar
    1 month ago

    Hi juninhofaquino 

    Based on the requirement as described, I do not think there is a fully supported native Matrix feature that does exactly this.

    Power BI does not first materialize the full Matrix result and then apply a pure display-only filter to hide rows. Slicers and visual-level filters are part of the visual query/evaluation process, and measures are evaluated in the current filter context. Therefore, when the filtering logic is based on a dynamic measure, Power BI must evaluate that measure in the context of the Matrix level currently being rendered.

    The closest supported approach is usually a disconnected status table plus a visibility measure, for example:

    Status Filter =
    DATATABLE(
    "Status", STRING,
    {
    { "All" },
    { "Above Target" },
    { "Below Target" }
    }
    )
    Show Row By Status =
    VAR SelectedStatus =
    SELECTEDVALUE ( 'Status Filter'[Status], "All" )
    VAR CurrentStatus =
    [STATUS PRAZO APRESENTAÇÃO (ACUMULADO DIÁRIO)]
    RETURN
    SWITCH(
    TRUE(),
    SelectedStatus = "All", 1,
    CurrentStatus = SelectedStatus, 1,
    0
    )

    Then use Status Filter[Status] in the slicer and place [Show Row By Status] in the visual-level filters of the Matrix, filtering it to is 1.

    However, this is not a true “post-calculation hide rows only” mechanism. The visibility measure is still evaluated by the Matrix at the current hierarchy level. This means that National, State, Pole, Month and Date rows may be evaluated differently depending on their current filter context. Totals are also measures evaluated in their own context, not simply frozen values from the unfiltered Matrix.

    So if the business requirement is strictly:

    calculate all Matrix values exactly as if no status filter exists;
    then only hide rows after the Matrix has already been calculated;
    without changing totals, accumulated values, or hierarchy behavior;

    then I would say this is currently not possible with the native Power BI Matrix visual.

    The practical alternatives are:

    Use the disconnected slicer + visual filter measure approach, accepting that it is still evaluated by the visual.
    Precompute the status at the required grain, if the status logic can be fixed at a specific grain such as Pole-Date.
    Use a separate reporting layout where the filtered and unfiltered versions are handled separately.
    Consider a custom visual or an external/paginated reporting approach if true post-processing/display-only filtering is mandatory.

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.