Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RafaelAri
Helper III
Helper III

Conditional formatting of Bar & Line visual

Hello,

I have a Bars + Line visual.

Bars = Monthly Income

Line = Monthly Target Income

I want to conditional-format the valuse of the line, so if it is over the Bar-value it will be Red and in it is under the Bar-value it will be Green

Other option is to conditional-format the Bars color (if it is over the Line-value it will be Green and in it is under the Line-value it will be Red)Conditional Format.png

 

1 ACCEPTED SOLUTION
Shivu-2000
Super User
Super User

Hi @RafaelAri 

Power BI doesn't offer direct conditional formatting for individual data points within a combined Bars + Line chart. 
But you can try these:

1: Dual Lines with Conditional Formatting

  1. Duplicate the Line Field: Duplicate the "Monthly Target Income" field in your data model.
  2. Create Calculated Column: Create a calculated column using DAX (Data Analysis Expressions). Here's an example formula:
Target Difference = 
VAR Target = SELECTEDVALUE('YourTable'[Monthly Target Income])
VAR Income = SELECTEDVALUE('YourTable'[Monthly Income])
RETURN
    IF(Target > Income, Target, BLANK())

This formula will return the target value only if it's greater than the income value. Otherwise, it will return a blank value.

  1. Add Dual Lines: Add two lines to your chart:

    • One line for the original "Monthly Target Income" field.
    • Another line for the newly created "Target Difference" calculated column.
  2. Conditional Formatting for Target Line: Apply conditional formatting to the original "Monthly Target Income" line. Set the line color to red when the value is greater than the corresponding value in the "Monthly Income" bar.

  3. Filtering the Target Difference Line: For the "Target Difference" line, use a filter to only show non-blank values. This will ensure the line only appears when the target is above income, appearing red alongside the bar.

2: Dual Bars with Conditional Formatting

  1. Duplicate the Bar Field: Duplicate the "Monthly Income" field in your data model.

  2. Create Calculated Column: Create a calculated column using DAX:

Income Difference = 
VAR Target = SELECTEDVALUE('YourTable'[Monthly Target Income])
VAR Income = SELECTEDVALUE('YourTable'[Monthly Income])
RETURN
    IF(Target < Income, Income, BLANK())

This formula will return the income value only if it's greater than the target value. Otherwise, it will return a blank value.

  1. Add Dual Bars: Add two bars to your chart:

    • One bar for the original "Monthly Income" field.
    • Another bar for the newly created "Income Difference" calculated column.
  2. Conditional Formatting for Income Bar: Apply conditional formatting to the original "Monthly Income" bar. Set the bar color to green when the value is greater than the corresponding value in the "Monthly Target Income" line.

  3. Filtering the Income Difference Bar: For the "Income Difference" bar, use a filter to only show non-blank values. This will ensure the bar only appears when the income is above target, appearing green alongside the line.




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

View solution in original post

3 REPLIES 3
RafaelAri
Helper III
Helper III

Thank you very much @Shivu-2000 ,

"Conditional Formatting for Income Bar: Apply conditional formatting to the original "Monthly Income" bar. Set the bar color to green when the value is greater than the corresponding value in the "Monthly Target Income" line"

 

But I don't have an option to compare Fields:


Conditional Format1.png

Swapnilmandloi
Resolver I
Resolver I

Hello,
To achieve conditional formatting based on your described conditions in Power BI, you can follow these steps:

  1. Edit Your Visual:

    • Select the Bars + Line visual on your Power BI report canvas.
  2. Conditional Formatting for the Line:

    • Click on the Line portion of your visual (the Monthly Target Income).
    • In the Visualizations pane, find the "Data colors" section under the Format tab.
  3. Set Conditional Formatting Rules:

    • Locate the "Conditional formatting" option within the Data colors section.
    • Click on "Conditional formatting" to expand it.
    • Add a new rule by clicking on "Add rule."
    • Choose "Field value" for the Type.
    • Define your rule:
      • Format by: Field value
      • Based on: Monthly Target Income
      • Apply color: Red for values greater than or equal to Monthly Income, and Green for values less than Monthly Income.
  4. Conditional Formatting for the Bars:

    • Click on the Bars portion of your visual (the Monthly Income).
    • Follow similar steps as above:
      • Navigate to the "Data colors" section in the Visualizations pane.
      • Click on "Conditional formatting."
      • Add a new rule:
        • Format by: Field value
        • Based on: Monthly Income
        • Apply color: Green for values greater than or equal to Monthly Target Income, and Red for values less than Monthly Target Income.
  5. Apply and Adjust:

    • Ensure both rules are applied correctly and adjust thresholds or colors as needed.
    • Preview your visual to see the conditional formatting in action.

By setting up these conditional formatting rules, you can dynamically color-code your Bars and Line visual based on the relationship between Monthly Income and Monthly Target Income as per your specified conditions.

Shivu-2000
Super User
Super User

Hi @RafaelAri 

Power BI doesn't offer direct conditional formatting for individual data points within a combined Bars + Line chart. 
But you can try these:

1: Dual Lines with Conditional Formatting

  1. Duplicate the Line Field: Duplicate the "Monthly Target Income" field in your data model.
  2. Create Calculated Column: Create a calculated column using DAX (Data Analysis Expressions). Here's an example formula:
Target Difference = 
VAR Target = SELECTEDVALUE('YourTable'[Monthly Target Income])
VAR Income = SELECTEDVALUE('YourTable'[Monthly Income])
RETURN
    IF(Target > Income, Target, BLANK())

This formula will return the target value only if it's greater than the income value. Otherwise, it will return a blank value.

  1. Add Dual Lines: Add two lines to your chart:

    • One line for the original "Monthly Target Income" field.
    • Another line for the newly created "Target Difference" calculated column.
  2. Conditional Formatting for Target Line: Apply conditional formatting to the original "Monthly Target Income" line. Set the line color to red when the value is greater than the corresponding value in the "Monthly Income" bar.

  3. Filtering the Target Difference Line: For the "Target Difference" line, use a filter to only show non-blank values. This will ensure the line only appears when the target is above income, appearing red alongside the bar.

2: Dual Bars with Conditional Formatting

  1. Duplicate the Bar Field: Duplicate the "Monthly Income" field in your data model.

  2. Create Calculated Column: Create a calculated column using DAX:

Income Difference = 
VAR Target = SELECTEDVALUE('YourTable'[Monthly Target Income])
VAR Income = SELECTEDVALUE('YourTable'[Monthly Income])
RETURN
    IF(Target < Income, Income, BLANK())

This formula will return the income value only if it's greater than the target value. Otherwise, it will return a blank value.

  1. Add Dual Bars: Add two bars to your chart:

    • One bar for the original "Monthly Income" field.
    • Another bar for the newly created "Income Difference" calculated column.
  2. Conditional Formatting for Income Bar: Apply conditional formatting to the original "Monthly Income" bar. Set the bar color to green when the value is greater than the corresponding value in the "Monthly Target Income" line.

  3. Filtering the Income Difference Bar: For the "Income Difference" bar, use a filter to only show non-blank values. This will ensure the bar only appears when the income is above target, appearing green alongside the line.




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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.