Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
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?
Solved! Go to Solution.
Hi @Anonymous ,
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.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Is what you want like below?
If so, based on my knowledge, I can't resolve it.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Icey,
Thank you for your help. Exactly what I want; If the value is 25, it will be green, if it is 40, then 25 of it will be green and 15 of it will be blue. But I understood the logic. I will try to apply.
@Anonymous 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.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
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.
@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.
Hi @Anonymous,
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.
@Anonymous 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.
Hi @Anonymous ,
Please share with us a specific example. Then, we can conduct specific tests.
Best Regards,
Icey
Hi @Icey,
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.
Hi @Anonymous ,
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.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Icey,
Thank you for answer the question.
I approached the desired result. The colors come right, but when I change the value from the database, the colors must come. For example; If the value is 25, the bar color will be green, when I update the value to 40, the bar color should be green up to 25 and the remaining 15 should be blue.
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?
Hi @Anonymous,
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?
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
89 | |
86 | |
82 | |
64 | |
49 |
User | Count |
---|---|
124 | |
110 | |
88 | |
68 | |
66 |