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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Roinka
Helper I
Helper I

Conditional bar color

Hi,

I have a bar chart which displays a list of categories and number of points in each category.

One of the categories is a control category.

I would like the chart to show all categories above the control category (=have more points comparing to control category) in one color (say blue), the control group in another color (say green) and everything below it in a different color (say red). 

E.g.:

category 1 - 100 pt (bar is in blue)

category 2 - 50 pt (bar is in blue)

Control category - 30 pt  (bar is in green)

Category 4 - 20 pt  (bar is in red)

Category 5 - 10 pt. (bar is in red)

Thank you.

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi Roinka

 

You will have to create some sort of measure that determines whether the sum of Points is greater than or less than the Control Category, and use that as the basis for conditional formatting.

 

Here is an example

 

In this example I created these measures:

Points Sum = 
SUM ( Points[Points] )

Points Sum Control Category = 
CALCULATE ( 
    [Points Sum],
    Points[Category] = "Control Category"
)

Bar Colour = 
    IF (
        SELECTEDVALUE ( Points[Category] ) = "Control Category",
        "green",
        VAR PointsSumRelativeToControl = 
            SIGN ( [Points Sum] - [Points Sum Control Category] )
        RETURN
            SWITCH (
                PointsSumRelativeToControl,
                1,"blue",
                0,"grey", // Grey for categories that happen to have points equal to control
                -1,"red"
            )
    )

In this example, the Bar Colour measure itself returns the name of the colour, so is used under Data colors => Conditional formatting => Field Value.

 

You should be able to adapt this to your needs.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
Omega
Impactful Individual
Impactful Individual

OwenAuger
Super User
Super User

Hi Roinka

 

You will have to create some sort of measure that determines whether the sum of Points is greater than or less than the Control Category, and use that as the basis for conditional formatting.

 

Here is an example

 

In this example I created these measures:

Points Sum = 
SUM ( Points[Points] )

Points Sum Control Category = 
CALCULATE ( 
    [Points Sum],
    Points[Category] = "Control Category"
)

Bar Colour = 
    IF (
        SELECTEDVALUE ( Points[Category] ) = "Control Category",
        "green",
        VAR PointsSumRelativeToControl = 
            SIGN ( [Points Sum] - [Points Sum Control Category] )
        RETURN
            SWITCH (
                PointsSumRelativeToControl,
                1,"blue",
                0,"grey", // Grey for categories that happen to have points equal to control
                -1,"red"
            )
    )

In this example, the Bar Colour measure itself returns the name of the colour, so is used under Data colors => Conditional formatting => Field Value.

 

You should be able to adapt this to your needs.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.