Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I need to conditionally format each row in a table differently. In the example table below, the threshold for what is "red", "yellow", or "green" is different for each row.
How do I conditionally format each row so that the threshold colors are properly captured for each row?
Hello @Dawg I’d recommend approaching this in three steps:
1) Add a column for each of the threshold values, this would mean adding a column for red to each your table becomes
| Red | Yellow | Green | 2024 | 2025 |
Item 1 | 3 | 2 | 1 | 3 | 2 |
Item 2 | 15 | 14 | 13 | 13 | 15 |
Item 3 | 30 | 20 | 10 | 30 | 10 |
2) Second step is to make a calculated column that determines the final color, this can be done using a switch statement like this:
_2024color = SWITCH(TRUE,
/* replace Query1 with your table name */
Query1[2024] <= Query1[Green],"green",
Query1[2024] <= Query1[Yellow],"yellow",
Query1[2024] <= Query1[Red],"red"
)
since you are using two columns here, you’ll have to add one for each value you want to color.
> Note: you can also use hex colors instead of the color name
3) Finally you can use conditional formatting to color the actual text box, select the column you want to change, enable conditional formatting, change the formatting style to “Field Value”, and set the value of “What field should we base this on?” to the calculated column we made in step 2.
Here's a diagram of the steps
You could also use formatting to change the color of other kinds of charts if you like.
Hi @Dawg Can you provide me a Sample data to work with ? So that I can provide you the DAX accordingly
Thanks,
Proud to be a Super User! | |