Forum Discussion

Renna's avatar
Renna
Frequent Visitor
2 years ago
Solved

Conditional Formatting for specific level of matrix

Hi, 
I want to apply conditional formatting ('Field Value', based on a measure) to only the top level of a matrix, regardless of its state (collapsed/expanded). 
It works well when "Totals Only" is selected and the matrix is expanded

but the formatting disappears upon collapsing to the top level:

Here is the measure: 

KPI = IF(ISINSCOPE('Sample Table'[Project Group]),
IF( SUM('Sample Table'[Revenue]) > 1000000, "Green", "Red"), BLANK())

I'd appreciate any guidance on this.



  • Renna 

    the idea is that the DAX code you wrote  ( the isinscope part )  will always be true on all levels,  

    because project group is the first level  , so all lower levels are inscope of the first level. 

     

    modify you code to this : 

    switch (

    true() , 

    isinscope( level 2 col of the matrix  ) , blank() , 

     ISINSCOPE('Sample Table'[Project Group]),

    if ( SUM('Sample Table'[Revenue]) > 1000000, "Green", "Red")

    )

     

     

    NB :

    you can use if statement . 

    i prefer switch for readability . 

     
     
    let me know if this works for you . 
     
     
    If my answer helped sort things out for you, i would appreciate a thumbs up πŸ‘ and mark it as the solution βœ…
    It makes a difference and might help someone else too. Thanks for spreading the good vibes! πŸ™

4 Replies

  • Daniel29195's avatar
    Daniel29195
    Community Champion

    Renna 

    when applying the conditional formatting, 

    apply it to total and values 

     

    hope this helps .

     

     

    If my answer helped sort things out for you, i would appreciate a thumbs up πŸ‘ and mark it as the solution βœ…
    It makes a difference and might help someone else too. Thanks for spreading the good vibes! πŸ™

    • Renna's avatar
      Renna
      Frequent Visitor

      Hi Daniel, 

      Thanks for your response. When I select Values and Totals, it works well when the matrix is collapsed: 

      But, it also applies to level 2, which I don't want: 

       

      • Daniel29195's avatar
        Daniel29195
        Community Champion

        Renna 

        the idea is that the DAX code you wrote  ( the isinscope part )  will always be true on all levels,  

        because project group is the first level  , so all lower levels are inscope of the first level. 

         

        modify you code to this : 

        switch (

        true() , 

        isinscope( level 2 col of the matrix  ) , blank() , 

         ISINSCOPE('Sample Table'[Project Group]),

        if ( SUM('Sample Table'[Revenue]) > 1000000, "Green", "Red")

        )

         

         

        NB :

        you can use if statement . 

        i prefer switch for readability . 

         
         
        let me know if this works for you . 
         
         
        If my answer helped sort things out for you, i would appreciate a thumbs up πŸ‘ and mark it as the solution βœ…
        It makes a difference and might help someone else too. Thanks for spreading the good vibes! πŸ™