cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

How do I color the stacked bar chart by Dax query according to the condition in Power BI?

Hello all,

 

I want to colorize the stacked bar chart according to the condition with Dax query in Power BI. For example; If (count <30) count value will turn green. If (count> 30 && count <60) count will take the color green and blue. How can I do that?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

Hi @esukrusenturk ,

 

Currently, Power BI doesn't support it directly. You could post your idea on Power BI Ideas.

It is a place for customers to provide feedback about Power BI.
What's more, if a feedback is highly voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version in the future.

 

However, there is a workaround.

1. Create measures like so:

Total Value = SUM('Table'[Value])
30 = IF([Total Value]<=30,[Total Value],30)
30-60 =
IF (
    [Total Value] <= 30,
    BLANK (),
    IF (
        [Total Value] > 30
            && [Total Value] <= 60,
        [Total Value] - 30,
        IF ( [Total Value] > 60, 30 )
    )
)
>60 = IF([Total Value]>=60,[Total Value]-60)

 

2. Create a Stacked bar chart.

bar.jpg

bar.PNG

 

Best Regards,

Icey

 

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

View solution in original post

12 REPLIES 12
Highlighted
Super User IV
Super User IV

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

@esukrusenturk you can use conditional formatting for the bar color and put the rules for formatting. Here is the doc on it.

 

Ask anything Power BI. Book free appointment at https://www.perytus.com 

 

Would appreciate Kudos 🙂 if my solution helped.

 

 






Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Highlighted
Helper III
Helper III

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

@parry2k Thank you for answering my question. I tried conditional formatting but I could not get the result I wanted. I want, for example; If (count> 30 & count <60) count value will be green and blue value will be added next to it. Just like the append in javascript.

 

Highlighted
Helper II
Helper II

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

Hi @esukrusenturk,

 

Follow the steps to have more control over conditional formatting - 

1) Create a measure 

 Color code = if(count < 30, "#008000","FF0000")

#FF0000 - hex code of red

#008000 - hex code of green

 

2) Go the values of the stacked bar chart, right click "Conditional Formatting", font color/background color.

3) Under "Format By", choose "Field Value"

4) Select the measure created in step 1.

 

This should give you expected results. 

Highlighted
Helper III
Helper III

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

@raimon Thank you for answering my question. I tried conditional formatting but I could not get the result I wanted. I want, for example; If (count> 30 & count <60) count value will be green and blue value will be added next to it. Just like the append in javascript.

Highlighted
Helper II
Helper II

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

Did you follow the steps ? Before applying conditional formatting, you will have to create a calculated measure. 

If the steps dint help, do you mind sharing the pbix?

Highlighted
Community Support
Community Support

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

Hi @esukrusenturk ,

 

Please share with us a specific example. Then, we can conduct specific tests.

 

 

Best Regards,

Icey

Highlighted
Helper III
Helper III

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

Hi @raimon,

 

Yes, don't follow the steps. I created a computed column before following the steps. But I still could not get the result I wanted. I want, for example; if (count> = 30 & count <= 60) shows green and blue in this range, that is, the bar shows two colors at the same time. I do not know how to share the .pbix yet I am very new. How can I share?

 

Highlighted
Helper III
Helper III

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

Hi @Icey,

 

ekran2.PNG

 

That's exactly what I want. When count exceeds 30, I want the values ​​below 30 to be green, the values ​​between 30 and 60 will be blue, and the values ​​above 60 will be red. In other words, when the value in the database is less than 30, it will show green on the screen, and between 30 and 60 it will show green and blue, and over 60 it will show green, blue and red.

Highlighted
Community Support
Community Support

Re: How do I color the stacked bar chart by Dax query according to the condition in Power BI?

Hi @esukrusenturk ,

 

Currently, Power BI doesn't support it directly. You could post your idea on Power BI Ideas.

It is a place for customers to provide feedback about Power BI.
What's more, if a feedback is highly voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version in the future.

 

However, there is a workaround.

1. Create measures like so:

Total Value = SUM('Table'[Value])
30 = IF([Total Value]<=30,[Total Value],30)
30-60 =
IF (
    [Total Value] <= 30,
    BLANK (),
    IF (
        [Total Value] > 30
            && [Total Value] <= 60,
        [Total Value] - 30,
        IF ( [Total Value] > 60, 30 )
    )
)
>60 = IF([Total Value]>=60,[Total Value]-60)

 

2. Create a Stacked bar chart.

bar.jpg

bar.PNG

 

Best Regards,

Icey

 

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

View solution in original post

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors