Forum Discussion

Randomlee's avatar
Randomlee
New Member
11 months ago
Solved

understanding filter context on Matrix visual

I have a measure which can be seen as the values in the matrix below. I have applied a greater than 4 filter on the visual using the same measure. The filter appears to work on all visuals (I've tested so far). However, as you can see when using the Matrix visual values less than 4 are shown. Does anyone understand why this is? 

 

  • Hi Randomlee 

    When you apply a measure filter like greater than 4 on a Matrix, it behaves differently than in a Table or Card. The Matrix first evaluates the measure at the group/parent level, and if that group total passes the filter, all its child rows are still displayed  even if some of them are below the threshold. That’s why you still see values < 4 inside the Matrix.

     

    To hide those detail rows properly, you need to blank them out with DAX logic. A working pattern is:

    Total Value =
    SUM ( Fact[Value] )
    Row Visible ( > 4 ) =
    VAR _th = 4
    RETURN
    IF (
       ISINSCOPE ( Fact[Subgroup] ),
           IF ( [Total Value] > _th, 1, 0 ),
           IF (
               CALCULATE (
                  COUNTROWS (
                      FILTER (
                          VALUES ( Fact[Subgroup] ),
                          CALCULATE ( [Total Value] ) > _th
                       )
                   )
               ) > 0, 1, 0
           )
    )
    Display Value ( > 4 only ) =
    VAR _th = 4
    RETURN
    IF (
       ISINSCOPE ( Fact[Subgroup] ) && [Total Value] <= _th,
       BLANK (),
       [Total Value]
    )

     

    Then build your Matrix like this:

    • Rows: AgeGroup >> Subgroup
    • Values: Display Value ( > 4 only )
    • Visual filter: Row Visible ( > 4 ) = 1

    Make sure Show items with no data is turned Off.

     

  • The Matrix visual keeps showing values less than 4 because the filter applies after the visual builds its rows and columns. To hide those smaller values, rewrite your measure like this:
    MeasureFiltered = IF([YourMeasure] > 4, [YourMeasure], BLANK())


    This blanks out values ≤4, making the Matrix omit or hide them properly.

3 Replies

  • Shahid12523's avatar
    Shahid12523
    Community Champion

    The Matrix visual keeps showing values less than 4 because the filter applies after the visual builds its rows and columns. To hide those smaller values, rewrite your measure like this:
    MeasureFiltered = IF([YourMeasure] > 4, [YourMeasure], BLANK())


    This blanks out values ≤4, making the Matrix omit or hide them properly.

    • Randomlee's avatar
      Randomlee
      New Member

      thanks rohit1991 for the explanation - I'd already started creating supressed small number measures 

      RETURN
          SWITCH(
              TRUE(),
              Result = 0, "0",
              Result < 5, "<5",
              Result
          )
  • Hi Randomlee 

    When you apply a measure filter like greater than 4 on a Matrix, it behaves differently than in a Table or Card. The Matrix first evaluates the measure at the group/parent level, and if that group total passes the filter, all its child rows are still displayed  even if some of them are below the threshold. That’s why you still see values < 4 inside the Matrix.

     

    To hide those detail rows properly, you need to blank them out with DAX logic. A working pattern is:

    Total Value =
    SUM ( Fact[Value] )
    Row Visible ( > 4 ) =
    VAR _th = 4
    RETURN
    IF (
       ISINSCOPE ( Fact[Subgroup] ),
           IF ( [Total Value] > _th, 1, 0 ),
           IF (
               CALCULATE (
                  COUNTROWS (
                      FILTER (
                          VALUES ( Fact[Subgroup] ),
                          CALCULATE ( [Total Value] ) > _th
                       )
                   )
               ) > 0, 1, 0
           )
    )
    Display Value ( > 4 only ) =
    VAR _th = 4
    RETURN
    IF (
       ISINSCOPE ( Fact[Subgroup] ) && [Total Value] <= _th,
       BLANK (),
       [Total Value]
    )

     

    Then build your Matrix like this:

    • Rows: AgeGroup >> Subgroup
    • Values: Display Value ( > 4 only )
    • Visual filter: Row Visible ( > 4 ) = 1

    Make sure Show items with no data is turned Off.