Forum Discussion
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
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
Yes you can use any colour you like...
Replace "Orange" with the hex colour code of your liking. e.g. "#FFFFFF"
6 Replies
- Angith_Nair
Continued Contributor
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
Solution 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])RETURNSWITCH(TRUE(),_Priority = 0, "Green",_Priority = 1, "Orange",_Priority = 2, "Red")- powerbiexpert22
Impactful Individual
- ajohnso2
Solution Supplier
Yes you can use any colour you like...
Replace "Orange" with the hex colour code of your liking. e.g. "#FFFFFF"
- Bibiano_Geraldo
Super User
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
- Kedar_Pande
Super User
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