Forum Discussion
Condition formatting
Hey All,
i want condition formatting on more then 1 condition.
if type A is above 10 then or below 10% is red and type B is above 5% green and below is red.
like:
Materials Type Values
Ball Pen A 10%
Ink Pen B 7%
Gold Pen C 15%
Regards,
Syed Muhammad Akber
Hi Akbera1
Can you please try this ?
Create a measure and use conditional formatting.ValueColor =SWITCH(TRUE(),MAX('Table'[Type]) = "A" && MAX('Table'[Values]) < 0.10, "#FF0000", -- RedMAX('Table'[Type]) = "A" && MAX('Table'[Values]) >= 0.10, "#00FF00", -- GreenMAX('Table'[Type]) = "B" && MAX('Table'[Values]) < 0.05, "#FF0000", -- RedMAX('Table'[Type]) = "B" && MAX('Table'[Values]) >= 0.05, "#00FF00", -- GreenBLANK())
If this answers your questions, kindly accept it as a solution and give kudos.
8 Replies
- wardy912Super User
Hi Akbera1
Add the following calculated column
ColorFormat = SWITCH( TRUE(), 'Table'[Type] = "A" && ('Table'[Values] > 0.10 || 'Table'[Values] < 0.10), "Red", 'Table'[Type] = "B" && 'Table'[Values] > 0.05, "Green", 'Table'[Type] = "B" && 'Table'[Values] < 0.05, "Red", BLANK() )Ensure the column is in decimal format.
Go to your table visual.
Click the dropdown on the Values column > Conditional formatting > Font color or Background color.
Choose Format by: Field value.
Select the ColorFormat column you just created.Please give a thumbs up and mark as solved if this helps, thanks!
- mdaatifraza5556Super User
Hi Akbera1
Can you please try this ?
Create a measure and use conditional formatting.ValueColor =SWITCH(TRUE(),MAX('Table'[Type]) = "A" && MAX('Table'[Values]) < 0.10, "#FF0000", -- RedMAX('Table'[Type]) = "A" && MAX('Table'[Values]) >= 0.10, "#00FF00", -- GreenMAX('Table'[Type]) = "B" && MAX('Table'[Values]) < 0.05, "#FF0000", -- RedMAX('Table'[Type]) = "B" && MAX('Table'[Values]) >= 0.05, "#00FF00", -- GreenBLANK())
If this answers your questions, kindly accept it as a solution and give kudos. - alish_bSuper User
Hey Akbera1 ,
You could also use a measure for this. Similar concept as a calculated column but this will be generated on the fly and then apply the conditional formatting on the 'Values' column based on Field value where you pass the measure as the field value (Please refer to the screenshot).
ConditionalFormat =
VAR TypeSelection = SELECTEDVALUE('SampleTable'[Type])
VAR ValueSelection = SUM('SampleTable'[Values])
RETURN
SWITCH(TRUE(),
TypeSelection = "A" && ValueSelection >= 0.10 , "Green",
TypeSelection = "A" && ValueSelection < 0.10, "Red",
TypeSelection = "B" && ValueSelection >= 0.05, "Green",
TypeSelection = "A" && ValueSelection < 0.05, "Red"
)Hope it helps!
- grazitti_sapnaSuper User
Hi Akbera1
Try this:
ColorFormat =
SWITCH(
TRUE(),
'Table'[Type] = "A" && 'Table'[Values] >= 0.10, "Green",
'Table'[Type] = "A" && 'Table'[Values] < 0.10, "Red",
'Table'[Type] = "B" && 'Table'[Values] >= 0.05, "Green",
'Table'[Type] = "B" && 'Table'[Values] < 0.05, "Red",
BLANK()
)
I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
Curious to explore more? [Discover here].
Let’s keep building smarter solutions together! - v-sshirivoluCommunity Support
Hi Akbera1 ,
Thank you for reaching out to Microsoft fabric community.Thanks for sharing your requirement. I’ve implemented the solution and validated it against your logic. Here's how I achieved it:
The data has been loaded and includes the following columns: Type, Materials, and Values, with the Values presented as decimal percentages.
Created a DAX Measure to return color codes based on conditions:
Color Format =
SWITCH(
TRUE(),
SELECTEDVALUE('Table'[Type]) = "A" && SELECTEDVALUE('Table'[Values]) <> 0.1, "#FF0000",
SELECTEDVALUE('Table'[Type]) = "B" && SELECTEDVALUE('Table'[Values]) > 0.05, "#00FF00",
SELECTEDVALUE('Table'[Type]) = "B" && SELECTEDVALUE('Table'[Values]) <= 0.05, "#FF0000",
BLANK()
)I’ve applied Conditional Formatting to the Values column -
Open the table visual, click the dropdown on the Values field, then select Conditional Formatting and choose Background color.
Set Format by to Field value, and for Based on field, select the Color Format measure.
Please find the attached .pbix file for your reference.
Regards,
Sreeteja.- v-sshirivoluCommunity Support
Hi Akbera1 ,
I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.- v-sshirivoluCommunity Support
Hi Akbera1 ,
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you