Forum Discussion
Data Visualization with Rule Based Color in Column Graph
- 4 years ago
arafmustavi please find a link to a file with a solution:
Data Visualization with Rule Based Color in Column Graph 2022-07-24.pbix
Hi arafmustavi ,
1. IF you want the whole consumed bar to become green or red:
As SpartaBI mentioned before, you can use conditional formatting to change the color. However if you want to generate a Bar Graph with Budget vs Consumption, you will not be able to use conditional formatting. You can use line and clustered column chart to achieve this goal.
Please try:
First add values to the field like this:
Then create a measure for conditional formatting :
Measure = IF(MAX('Table'[Consumed])>MAX('Table'[Budget]),"Red","Green")
Apply it to the columns
Turn on the Data labels:
Final output:
2. If you want the part of the bar that below the budget line become green and the over part become red:
Please try:
Create these measure:
Below Budget = IF(MAX('Table'[Consumed])>MAX('Table'[Budget]),MAX('Table'[Budget]),MAX('Table'[Consumed]))
Over Budget = IF(MAX('Table'[Consumed])>MAX('Table'[Budget]),MAX('Table'[Consumed])-MAX('Table'[Budget]),0)
Then apply it to stacked bar chart:
Use these measure to create constant line:
Line A = MAXX(FILTER('Table',[Category]="A"),[Budget])
Line B = MAXX(FILTER('Table',[Category]="B"),[Budget])
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.