Forum Discussion

MikePowerBI's avatar
MikePowerBI
Helper II
5 months ago
Solved

Conditional Formatting with Different Thresholds per Category

Hi there,   I have a matrix (screenshot below) with example data. The matrix takes the median shipment time in days for different shipment categories in different regions.    I am looking t...
  • cengizhanarslan's avatar
    5 months ago

    Step 1) Create a color measure

    CF Color =
    VAR _Value = [Median Shipment Days]
    VAR _Type = SELECTEDVALUE('Shipment'[Type])
    RETURN
    SWITCH(
        TRUE(),
    
        // Air
        _Type = "Air Shipment" && _Value < 10, "#00B050",       -- Green
        _Type = "Air Shipment" && _Value < 20, "#FFC000",       -- Yellow
        _Type = "Air Shipment" && _Value >= 20, "#C00000",      -- Red
    
        // Boat
        _Type = "Boat Shipment" && _Value < 30, "#00B050",
        _Type = "Boat Shipment" && _Value < 50, "#FFC000",
        _Type = "Boat Shipment" && _Value >= 50, "#C00000",
    
        // Ground
        _Type = "Ground Shipment" && _Value < 20, "#00B050",
        _Type = "Ground Shipment" && _Value < 30, "#FFC000",
        _Type = "Ground Shipment" && _Value >= 30, "#C00000"
    )

     

    Step 2) Apply it in the matrix

    1. Select your matrix
    2. Go to Conditional formatting → Background color (or Font color)
    3. Choose Format by: Field value
    4. Select CF Color