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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JonasWillmann
New Member

Get conditional Bar Chart Colors for a variable value.

Hello Power-Bi Community,

sorry if there is an obvious solution i am quite new.

 

I have 2 values in my data which show calls and expected calls. Both are changing with the selected timeframe and employee etc.

 

I want the bars in the chart to be green if the calls are >= expected calls, and red otherwise.

While searching the forums i think i need to define a new meassure but i am quite unsure about how to do that exactly and what syntax to use.

Thank you for the help

JW

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @JonasWillmann 

 

The measure you need is something like 

Conditional Colors = INT( SUM( 'Yor Table'[calls] ) >= SUM( 'Yor Table'[expected calls] ) )

Later you can use it for conditional formatting like on scr below.

image.png

This will give you the following result.

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

View solution in original post

7 REPLIES 7
Mariusz
Community Champion
Community Champion

Hi @JonasWillmann 

 

The measure you need is something like 

Conditional Colors = INT( SUM( 'Yor Table'[calls] ) >= SUM( 'Yor Table'[expected calls] ) )

Later you can use it for conditional formatting like on scr below.

image.png

This will give you the following result.

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Thank you!

Works like a charm

Hi @JonasWillmann 

 

Happy to help!

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski



@Mariusz 

One additional question, is it possible to call the selected dimensions in the formula for the measure? if i click a month for example it shrinks the bars to a preview value without drilling down. The color stays the same since the month is not used as a filter yet.

 

Best regards

JonasWillmann

Hi @JonasWillmann 


Not sure if I understand the question, but if you use any additional filters the conditional formatting measure should react in the same way, as long as the base measures or aggregations used in the calculation do not have any code that modifies the filter context.


Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski



 

 

 

Hello @Mariusz ,

 

thank you for helping me still.

Let me try to clarify:

Screenshot_2.png

 

 

 

 

 

 

This is the normal and wanted behaviour.

Screenshot_3.png

This is the normal and wanted behaviour if i filter (drill down in the pie-chart) for the first 4 months.

Screenshot_4.png

This is the view if i select the first four months in the piechart without drilling down. It shows a preview for the selected value without really applying the filter. Think it would be great if i could change the colors in this state to the same like in the second picture.

 

Best Regards

Jonas

Hi @JonasWillmann 

 

You need to change the interactivity as below, by doing this you will start applying filters rather then just highlight.

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.