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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Conditional Formatting for Color in Bar Chart

Hi,
Let say I have below table

NetworkProduct
Network APencil
Network ABook
Network APen
Network BKnife
Network BPan
Network CBed
Network C

Pillow

 

I want to make a bar chart for [Product] where the color is indicated by [Network]. I found the conditional formatting in Data Color only available for numerical rules (CMIW). Hope you can prove me wrong and find the alternative solution for this.

 

Thank you for your help.

Vano

7 REPLIES 7
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description and Follow-up, I can clearly understand clearly what you want to get, you can create a measure like this:

Color =

SWITCH(

    MAX('Table'[Network]),

    "Network A","Red",

    "Network B","Yellow",

    "Network C","Grey")

Then you can create a column chart and place it like this, then set the conditional format for the data color using lkalawski’s solution, like this:

v-robertq-msft_0-1613531236568.png

 

v-robertq-msft_1-1613531236575.png

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

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

lkalawski
Super User
Super User

Hi @Anonymous 

What do you want to achieve by using bar chart? Do you want to have number of product for each network and color each bar based on the network name? Can you draw your idea? 




Proud to be a Super User.
If I helped, please accept the solution and give kudos
LinkedIN

 

Anonymous
Not applicable

Hi @lkalawski,

 

Yes, exactly what you said. I want to draw a bar graph of number of product with color indication based on network. The amount number of product here doesn't really matter. You can put any number for each product.

@Anonymous 

You can create a measure which will indicate which network is selected and in this measure you can assign colors for each network:

Selected Network = 
VAR __selectedNetwork = SELECTEDVALUE('Table'[Network])
RETURN
    SWITCH(__selectedNetwork,
    "Network A", "Red",
    "Network B", "Blue",
    "Network C", "Yellow"
    )

and then in the settings of bar chart you can use this measure as a data colors:

 

lkalawski_4-1611654928245.png lkalawski_5-1611654951078.png

 

 

The result:

lkalawski_0-1611654844912.png




Proud to be a Super User.
If I helped, please accept the solution and give kudos
LinkedIN

 

Anonymous
Not applicable

Hi @lkalawski ,

 

This looks really good. But what I want is to have the bar chart for the [Product] field. So there will be 7 bars with 3 different colors (e.g. Pencil, Book, Pen in red color).

Hi @Anonymous 

So, my solution will also work. You only have to change the Axis value in the chart: instead of Network please use Product. Conditional formatting should be as previous. 

 

PBI_SuperUser_Rank@1x.png Proud to be a Super User.
If I helped, please accept the solution and give kudos
Linkedin

 

Anonymous
Not applicable

Hi @lkalawski ,

 

I tried to use this measure but it didn't work. The only things that worked is when you put else statement. I tried to check on my data value and changed it to text type but still didn't work.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.