Forum Discussion
Easy Conditional Text based on column values
- Anonymous4 years ago
Hi PowerrrBrrr ,
Here are the steps you can follow:
1. Create measure.
color = IF( MAX('Table'[Value])=0,"red","green" )status = IF( MAX('Table'[Value])=0,"Inactive","Running")2. Select Format – Conditional formatting – Machines – Background color.
3. Enter the Background color interface.
Format by – Field value
Based on field – [color]
4. Result:
Does this match your expected result?
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Here is the data table. So if you see Machine 3 will be showing Red and should show "Inactive" while all other machine are showing green but should show text "Running" also
| Machines | Value | Timestamp |
| Machine1 | 23 | 2021-08-12 |
| Machine2 | 2 | 2021-09-08 |
| Machine3 | 0 | 2021-09-01 |
| Machine1 | 11 | 2021-08-23 |
Hi PowerrrBrrr ,
Create following measure for giving a background color based on text value:
conditionalColor =
VAR t1 =
SELECTEDVALUE ( conditionalData[Machines] )
RETURN
SWITCH ( TRUE (), t1 = "Machine3", "#ff0000", "#009900" )
Then you can use above measure to get dynamic background color for Machines column, something like below:
Similarly, you can create another measure for Running/Inactive text:
conditionalStatus =
var t1 = SELECTEDVALUE(conditionalData[Machines])
RETURN
SWITCH(
TRUE(),
t1 = "Machine3", "Inactive", "Running"
)
You will something as below:
Let me know how you get along with this solution.
Thanks,
Pragati
- PowerrrBrrr4 years ago
Helper III
But here you are putting Machine 3 as Red and Inactive in your Formulae. In my case it can be any machine.. Machine 3 I gave as an example
- Pragati114 years ago
Super User
HI PowerrrBrrr ,
In that case you need to write a set of rules for me to create a measure. 🙂
You can even modify the above measures based on your requirement.
Also, I don't understand what do you mean by - any machine. Do you want your Machine column value coming from a slicer or how you want it to be?
Thanks,
Pragati
- PowerrrBrrr4 years ago
Helper III
I gave the rule it is when Value is 0. I dont see anywhere in your DAX that you are checking this condition. you are simply selecting the Machine column and for machine 3 you are putting it as RED. We need to have condition to set it as red when value is 0 and that I have already done with conditional formatting. I am now looking to get conditional text based on value