Forum Discussion

powerbiexpert22's avatar
powerbiexpert22
Icon for Impactful Individual rankImpactful Individual
1 year ago
Solved

different background color for each value

i want to add column in below table which should show different background color for each priorty . example it should show  green background for 0, orange for 1 and red for 2, the column should not show any data

 

 

  • Hi powerbiexpert22 

    Create a measure that will display the priority. Apply background conditional formatting for this measure something like the below dax:

    PriorityColor = 
    SWITCH(
        TRUE(),
        TableName[Priority] = 0, "Green",
        TableName[Priority] = 1, "Orange",
        TableName[Priority] = 2, "Red",
        BLANK()
    )

    To ensure the column does not display any values make sure to format the text color to match the background color (via Conditional Formatting for text). Alternatively, make the font color transparent or very light so it blends with the table.

  • Hi powerbiexpert22,

    Add a measure using the following DAX 

    Priority Color = BLANK()

     

    Now drag and drop the color measure to your Matrix, and add a conditional format as shown bellow:


    Now configure the prompt screen to something like this and hit ok:


    Now your table, should look like this:

     

    I hope this was heplful, if yes please accept as solution and give a kudo.

     

    Thank you

6 Replies

  • Angith_Nair's avatar
    Angith_Nair
    Icon for Continued Contributor rankContinued Contributor

    Hi powerbiexpert22 

    Create a measure that will display the priority. Apply background conditional formatting for this measure something like the below dax:

    PriorityColor = 
    SWITCH(
        TRUE(),
        TableName[Priority] = 0, "Green",
        TableName[Priority] = 1, "Orange",
        TableName[Priority] = 2, "Red",
        BLANK()
    )

    To ensure the column does not display any values make sure to format the text color to match the background color (via Conditional Formatting for text). Alternatively, make the font color transparent or very light so it blends with the table.

  • ajohnso2's avatar
    ajohnso2
    Icon for Solution Supplier rankSolution Supplier

    Hey,

    You can create a measure to control the different colours and use that measure for conditional formatting.

     

    Priority Colour =
    VAR _Priority = MAX('Priority'[priority])
    RETURN
    SWITCH(
        TRUE(),
        _Priority = 0, "Green",
        _Priority = 1, "Orange",
        _Priority = 2, "Red"
    )
     

     

  • Hi powerbiexpert22,

    Add a measure using the following DAX 

    Priority Color = BLANK()

     

    Now drag and drop the color measure to your Matrix, and add a conditional format as shown bellow:


    Now configure the prompt screen to something like this and hit ok:


    Now your table, should look like this:

     

    I hope this was heplful, if yes please accept as solution and give a kudo.

     

    Thank you

  • powerbiexpert22 

    Create a new calculated column to hold blank values (it will serve as the placeholder for formatting):

    BlankColumn = BLANK()

    Create a measure to define the color logic for each priority:

    PriorityColor = 
    SWITCH(
    TRUE(),
    'YourTable'[Priority] = 0, "#00FF00", 
    'YourTable'[Priority] = 1, "#FFA500", 
    'YourTable'[Priority] = 2, "#FF0000", 
    "#FFFFFF" -- Default to white
    )

    In the Conditional Formatting settings for BlankColumn, select the PriorityColor measure as the field for background color.

     

    💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
    Cheers,
    Kedar
    Connect on LinkedIn