Forum Discussion

Kavya123's avatar
Kavya123
Helper III
5 years ago
Solved

Conditional color coding in Bar chart

Hi Everyone,

I need to apply condition in bar chart for color coding.  I need output like below screenshot. 

ID 1 is having four desc values. The Company ID 100 is associated with desc value 'AAA' for ID 1 . If I select company ID 100 and ID 1 then I should get all four desc bars and the bar 'AAA' should highlight in red color. Please help me to achieve this in bar chart.

This is the sample data.

Company ID , ID, Desc

100,1,AAA

200,1,BBB

300,1,CCC

400,1,DDD

100,2,EEE

200,2,FFF

300,2,GGG

 

Thanks in advance

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Kavya123 

    This issue should be caused by Max function in color measure, it will always catch the max Company ID in same Desc. So when you have 100 and 200 in AAA(Desc) in 1(ID), only click 200 will show red. Try values function to get Company ID in Data Table. The new measure is as below.

    Color Measure 1 = 
    VAR _SELECTCompanyID = SELECTEDVALUE('Company ID'[Company ID])
    VAR _VALUES= VALUES('New Table'[Company ID])
    RETURN
    IF(_SELECTCompanyID IN _VALUES,"Red","Yellow")

    Result is as below.

    Best Regards,
    Rico Zhou

     

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

     

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Kavya123 

    I think you need to build an unrelated Company ID table to create the slicer to achieve your goal. If you use Company ID column in the same table, your color measure will disable, due to all Company IDs are selected all the same. 

    Unrelated Company ID table:

    Company ID = 
    VALUES('Table'[Company ID])

    Measure is as below.

    Color Measure = 
    VAR _SELECTCompanyID = SELECTEDVALUE('Company ID'[Company ID])
    RETURN
    IF(MAX('Table'[Company ID]) = _SELECTCompanyID,"Red","Yellow")

    Find Data color in Format, click fx, format by field value and select this color measure.

    Result is as below.

    Best Regards,
    Rico Zhou

     

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

     

    • Kavya123's avatar
      Kavya123
      Helper III
      Hi Ricozhou,
       
      Thanks for your response. In my case few descriptions are repeating. It is working for Company Id 200 and for company ID 100 color is not changing.

      Company ID , ID, Desc

      100,1,AAA

      200,1,AAA

      300,1,DDD

      400,1,DDD

      100,2,EEE

      200,2,FFF

      300,2,GGG

       

       

       


       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Kavya123 

        This issue should be caused by Max function in color measure, it will always catch the max Company ID in same Desc. So when you have 100 and 200 in AAA(Desc) in 1(ID), only click 200 will show red. Try values function to get Company ID in Data Table. The new measure is as below.

        Color Measure 1 = 
        VAR _SELECTCompanyID = SELECTEDVALUE('Company ID'[Company ID])
        VAR _VALUES= VALUES('New Table'[Company ID])
        RETURN
        IF(_SELECTCompanyID IN _VALUES,"Red","Yellow")

        Result is as below.

        Best Regards,
        Rico Zhou

         

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

         

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Kavya123 Are you slicers and bar chart columns all coming from the same table? If so then do you have interactions turned off between the slicers and the bar chart?

    • Kavya123's avatar
      Kavya123
      Helper III

      Hi,

      Thanks for your response. Yes slicers and bar chart columns all coming from the same table.

      This is the sample data.

      Company ID , ID, Desc

      100,1,AAA

      200,1,BBB

      300,1,CCC

      400,1,DDD

      100,2,EEE

      200,2,FFF

      300,2,GGG