Forum Discussion

mianjalil239's avatar
mianjalil239
Helper III
1 year ago
Solved

Who Can do This ?

Subject: Conditional Formatting on a Clustered Column Chart – How to Apply Conditional Formatting to Only One Column (Actual vs. Target)

Question:

Hello Power BI Community,

I’m trying to apply conditional formatting to the Actual column in a Clustered Column Chart, but I’m facing an issue. Here's what I've done:

  1. I created a Budget MTD measure like this:

java

Copy code

Budget MTD =

SWITCH(

    SELECTEDVALUE('KPI'[KPI]),

    "Actual", [MTD Budget Actual],

    "Target", [MTD Budget Target]

)

  1. I created another measure for conditional formatting:

css

Copy code

Actual Color Measure =

IF([MTD Budget Actual] > [MTD Budget Target], 1, 0)

  1. Then, I applied conditional formatting to the Budget MTD measure using the Actual Color Measure. The idea is to color the Actual column Red if it exceeds the Target, and Green otherwise.

However, despite following these steps, the conditional formatting is applying to both Actual and Target columns. I want the conditional formatting to be applied only to the Actual column, not the Target column.

Has anyone encountered this issue or can provide a solution to apply the conditional formatting only to the Actual column in a Clustered Column Chart?

I’d really appreciate any help.

Thank you!

  • Anonymous's avatar
    Anonymous
    1 year ago

    Thanks for the reply from DataNinja777  , please allow me to provide another insight:

    Hi, mianjalil239 
    Thanks for reaching out to the Microsoft fabric community forum.

    Regarding the issue you raised, my solution is as follows:

    Your initial approach is correct. Based on my testing, Conditional Formatting is available in the y-axis parameter of the Clustered Column Chart visual object only when there is a single field.


    Therefore, you simply need to add an additional condition to your Actual Color Measure:

    1.Firstly, my test data is as follows:

    2.Secondly, I have modified your Actual Color Measure to:

     

    Actual Color Measure =
    IF (
        SELECTEDVALUE ( 'KPI'[KPI] ) = "Actual",
        IF ( [MTD Budget Actual] > [MTD Budget Target], "#FF0000", "#00FF00" )
    )

     

    3.Next, adjust the custom visual object settings:

    4.Here's my final result, which I hope meets your requirements.

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • Hi mianjalil239 ,

     

    To apply conditional formatting to only the Actual column in a Clustered Column Chart in Power BI, you need to avoid using a combined measure like Budget MTD for conditional formatting. Instead, separate the Actual and Target values into distinct measures. This allows you to target the Actual series specifically for conditional formatting without affecting the Target column.

    First, create separate measures for the Actual and Target values:

    Actual MTD = [MTD Budget Actual]
    Target MTD = [MTD Budget Target]
    

    Next, create a conditional formatting measure that returns a color based on whether the Actual value exceeds the Target. This measure should output a hex color code to be used in the chart's formatting:

    Actual Color Measure =
    SWITCH(
        TRUE(),
        [MTD Budget Actual] > [MTD Budget Target], "#FF0000",  // Red for Actual > Target
        "#00FF00"  // Green for Actual <= Target
    )
    

    To apply this conditional formatting to the Actual series, select your Clustered Column Chart in the Visualizations pane. Click the dropdown arrow next to the Actual MTD series in the Values field. Select Data colors, then click the fx (Conditional formatting) icon. In the conditional formatting window, choose Field value as the formatting option and select the Actual Color Measure. Click OK to apply the formatting.

    The issue you experienced occurs because applying conditional formatting to a combined measure like Budget MTD affects all series in the chart. By separating the measures and applying the conditional formatting to only the Actual series, you ensure that only the Actual column is colored based on the condition.

    If you want to add more granular control, such as using yellow for values close to the target, you can adjust the Actual Color Measure to include additional conditions:

    Actual Color Measure =
    SWITCH(
        TRUE(),
        [MTD Budget Actual] > [MTD Budget Target], "#FF0000",  // Red for over Target
        [MTD Budget Actual] >= ([MTD Budget Target] * 0.9), "#FFFF00",  // Yellow for close to Target
        "#00FF00"  // Green for on or under Target
    )
    

    With this setup, the Actual column will turn red if the value exceeds the Target, yellow if it is close to the Target, and green otherwise. The Target column will remain unaffected by the conditional formatting.

     

    Best regards,

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from DataNinja777  , please allow me to provide another insight:

    Hi, mianjalil239 
    Thanks for reaching out to the Microsoft fabric community forum.

    Regarding the issue you raised, my solution is as follows:

    Your initial approach is correct. Based on my testing, Conditional Formatting is available in the y-axis parameter of the Clustered Column Chart visual object only when there is a single field.


    Therefore, you simply need to add an additional condition to your Actual Color Measure:

    1.Firstly, my test data is as follows:

    2.Secondly, I have modified your Actual Color Measure to:

     

    Actual Color Measure =
    IF (
        SELECTEDVALUE ( 'KPI'[KPI] ) = "Actual",
        IF ( [MTD Budget Actual] > [MTD Budget Target], "#FF0000", "#00FF00" )
    )

     

    3.Next, adjust the custom visual object settings:

    4.Here's my final result, which I hope meets your requirements.

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi,mianjalil239 
        We are absolutely delighted to hear that the issue has been resolved. If you’re inclined, you might consider accepting this solution, as it could also assist other community members facing the same problem, enabling them to find a resolution more swiftly
        .

        Of course, if there is anything else we can do for you, please do not hesitate to contact us.

        Looking forward to your reply.

        Best Regards,

        Leroy Lu