Forum Discussion

jerryr0125's avatar
jerryr0125
New Member
7 months ago
Solved

Visualization - Matrix - change background color based upon specifc columns

Hi -

I have a matrix visualization and I know that you can add a gradiant background color based upon the highest to lowet values.

I would like hav the background color change dynamically as well as foucs on a specific column.  That is, as an example, for each column in the matrix, highlight the top 3 values.  Something like this:

 

Green - highest; Yellow - 2nd highest; Red - thrid highest Thanks - appreciate it! Jerry

 

 

 

  • Assume your value measure is:

    [Sales] = SUM(Fact[Sales])

     

    Create a rank measure (ranks products within the current Store column):

    Rank in Store =
    RANKX(
        ALLSELECTED(Products[Product]),
        [Sales],
        ,
        DESC,
        Dense
    )

     

    Now create a color measure:

    Top 3 Color =
    VAR r = [Rank in Store]
    RETURN
    SWITCH(
        TRUE(),
        r = 1, "#C6EFCE",   -- green
        r = 2, "#FFEB9C",   -- yellow
        r = 3, "#F8CBAD",   -- red
        BLANK()
    )

     

    Apply it:

    • Select the Matrix

    • In the Values field dropdown (the measure you’re coloring) → Conditional formatting → Background color

    • Format by: Field value

    • Based on field: [Top 3 Color]

4 Replies

  • Assume your value measure is:

    [Sales] = SUM(Fact[Sales])

     

    Create a rank measure (ranks products within the current Store column):

    Rank in Store =
    RANKX(
        ALLSELECTED(Products[Product]),
        [Sales],
        ,
        DESC,
        Dense
    )

     

    Now create a color measure:

    Top 3 Color =
    VAR r = [Rank in Store]
    RETURN
    SWITCH(
        TRUE(),
        r = 1, "#C6EFCE",   -- green
        r = 2, "#FFEB9C",   -- yellow
        r = 3, "#F8CBAD",   -- red
        BLANK()
    )

     

    Apply it:

    • Select the Matrix

    • In the Values field dropdown (the measure you’re coloring) → Conditional formatting → Background color

    • Format by: Field value

    • Based on field: [Top 3 Color]

  • v-tejrama's avatar
    v-tejrama
    Community Support

    Hi jerryr0125 ,

     

    Thank you lbendlin  for the response provided!

    Has your issue been resolved? If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

    Thank you.

    • v-tejrama's avatar
      v-tejrama
      Community Support

      Hi jerryr0125 ,

       

      I wanted to follow up and see if you had a chance to review the information shared. If you have any further questions or need additional assistance, feel free to reach out.

      Thank you.