Forum Discussion

jerryr0125's avatar
jerryr0125
New Member
8 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 a...
  • cengizhanarslan's avatar
    8 months ago

    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]

  • lbendlin's avatar
    8 months ago

     

    or as a measure