Forum Discussion
Anonymous
1 year agoNot applicable
Conditional formatting based on category and value range
Hi All I asked this yesterday but accidentally closed the thread, I have been asked to create a new set of thresholds for a bar chart so that the color of the bar is based on a value range for ea...
- 1 year ago
Hi Anonymous
Can you please try the steps below to achieve your result?
1. Create a measure.Bar Color =SWITCH(TRUE(),// Category 1SELECTEDVALUE('Table'[Category]) = "Category 1" && [total value] >= 895, "#FF0000", -- RedSELECTEDVALUE('Table'[Category]) = "Category 1" && [total value] <= 649, "#00FF00", -- GreenSELECTEDVALUE('Table'[Category]) = "Category 1", "#FFC000", -- Amber// Category 2SELECTEDVALUE('Table'[Category]) = "Category 2" && [total value] >= 1000, "#FF0000",SELECTEDVALUE('Table'[Category]) = "Category 2" && [total value] <= 705, "#00FF00",SELECTEDVALUE('Table'[Category]) = "Category 2", "#FFC000",// Default"#FFFFFF")2. Apply the measure in conditional formattinga. Click on the bar chart.b. In the visualization pane, go to the Format section expand column.c. Clcik the fx button next Default color.d. Choose.--- Format by Field value----Based on field select the bar color measuer we created.If this answers your questions, kindly accept it as a solution and give kudos.
mdaatifraza5556
Super User
1 year agoHi Anonymous
Can you please try the steps below to achieve your result?
1. Create a measure.
Bar Color =
SWITCH(
TRUE(),
// Category 1
SELECTEDVALUE('Table'[Category]) = "Category 1" && [total value] >= 895, "#FF0000", -- Red
SELECTEDVALUE('Table'[Category]) = "Category 1" && [total value] <= 649, "#00FF00", -- Green
SELECTEDVALUE('Table'[Category]) = "Category 1", "#FFC000", -- Amber
// Category 2
SELECTEDVALUE('Table'[Category]) = "Category 2" && [total value] >= 1000, "#FF0000",
SELECTEDVALUE('Table'[Category]) = "Category 2" && [total value] <= 705, "#00FF00",
SELECTEDVALUE('Table'[Category]) = "Category 2", "#FFC000",
// Default
"#FFFFFF"
)
2. Apply the measure in conditional formatting
a. Click on the bar chart.
b. In the visualization pane, go to the Format section expand column.
c. Clcik the fx button next Default color.
d. Choose.
--- Format by Field value
----Based on field select the bar color measuer we created.
If this answers your questions, kindly accept it as a solution and give kudos.