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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Kavya123
Helper III
Helper III

Dynamically changing colors in Bar chart

Hi Everyone,

 

I have a requirenment to display a different color for bar based on the condition.

 

In the below screenshot the text Internal Audit (3rd line of Defense) is coming from Table 1, and the bar chart with Y axis values are coming from Table 2.  The requirenment is to display Internal Audit (3rd line of Defense) ( 2nd bar) bar in any different color (for example red). I want to compare the texts from both the tables and the matched texts should show in different color.

 

pic.png

Please find the below sample data. If we select  the filter Company A  then in the bar chart Internal Audit (3rd line of Defense) bar should higlight in diffent colour since the company A 's text value is Internal Audit (3rd line of Defense).

 

 

Table 1  
Text Company 
Internal Audit (3rd line of Defense)A
Direct assistance
Management testingB
Other (please describe)C
  
Table 2  
Text valueMeasure
Internal Audit (3rd line of Defense)10
Direct assistance20
Other (please describe)30

 


Please help me to achieve this.

 

 

Thanks in advance.

1 ACCEPTED SOLUTION

@Kavya123

 

Try modifying the measure as

 

Measure 2 =
IF ( VALUES ( Table2[Text value] ) IN VALUES ( Table1[Text ] ), "#6c1610" )

 


Regards
Zubair

Please try my custom visuals

View solution in original post

9 REPLIES 9
Zubair_Muhammad
Community Champion
Community Champion

@Kavya123

 

See the file attached as well

 

vonform.png


Regards
Zubair

Please try my custom visuals

Hi  Zubair Muhammad,

 

Thanks for ther reply. It is working for single text value. For company B there are two texts. If i select company B (Direct assistance,Management testing) both bars should highlight.

@Kavya123

 

Try modifying the measure as

 

Measure 2 =
IF ( VALUES ( Table2[Text value] ) IN VALUES ( Table1[Text ] ), "#6c1610" )

 


Regards
Zubair

Please try my custom visuals

Sorry for hijacking the thread, but how do i make the highlight function work when all the values (text and measure) are in the sambe table? 

@Zubair_Muhammad

 

Is it possible to format  colors both by rules and field value together. The matched text bar should highlight the color based on the rules.

 

For example if we select gold color, the matched text bar should highlight in red color and remaining bars should be gold colors.

pic.png

@Kavya123

 

Sorry for late reply.

See if the attached file helps

 

You can create a small table defining colors and hex codes.

You can get codes from

 

https://www.w3schools.com/colors/colors_picker.asp

 

colorcodes.png

 

Now you can modify the MEASURE AS

 

Measure 2 =
IF (
    VALUES ( Table2[Text value] ) IN VALUES ( Table1[Text ] ),
    MIN ( Colors[HexCode] )
)

Regards
Zubair

Please try my custom visuals

Thanks a lot for the solution. 

Thanks a lot  it worked.

Zubair_Muhammad
Community Champion
Community Champion

Hi @Kavya123

 

you can Define a MEASURE like following and use it for conditional formatting

 

Measure 2 =
IF (
    SELECTEDVALUE ( Table2[Text value] ) = SELECTEDVALUE ( Table1[Text ] ),
    "#6c1610"
)

 

 


Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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