Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Conditional Formatting for Color in Bar Chart

Hi,
Let say I have below table

NetworkProduct
Network APencil
Network ABook
Network APen
Network BKnife
Network BPan
Network CBed
Network C

Pillow

 

I want to make a bar chart for [Product] where the color is indicated by [Network]. I found the conditional formatting in Data Color only available for numerical rules (CMIW). Hope you can prove me wrong and find the alternative solution for this.

 

Thank you for your help.

Vano

7 Replies

  • lkalawski's avatar
    lkalawski
    Resident Rockstar

    Hi Anonymous 

    What do you want to achieve by using bar chart? Do you want to have number of product for each network and color each bar based on the network name? Can you draw your idea? 




    Proud to be a Super User.
    If I helped, please accept the solution and give kudos
    LinkedIN

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi lkalawski,

       

      Yes, exactly what you said. I want to draw a bar graph of number of product with color indication based on network. The amount number of product here doesn't really matter. You can put any number for each product.

      • lkalawski's avatar
        lkalawski
        Resident Rockstar

        Anonymous 

        You can create a measure which will indicate which network is selected and in this measure you can assign colors for each network:

        Selected Network = 
        VAR __selectedNetwork = SELECTEDVALUE('Table'[Network])
        RETURN
            SWITCH(__selectedNetwork,
            "Network A", "Red",
            "Network B", "Blue",
            "Network C", "Yellow"
            )

        and then in the settings of bar chart you can use this measure as a data colors:

         

         

         

         

        The result:




        Proud to be a Super User.
        If I helped, please accept the solution and give kudos
        LinkedIN

         

  • v-robertq-msft's avatar
    v-robertq-msft
    Community Support

    Hi, Anonymous 

    According to your description and Follow-up, I can clearly understand clearly what you want to get, you can create a measure like this:

    Color =
    
    SWITCH(
    
        MAX('Table'[Network]),
    
        "Network A","Red",
    
        "Network B","Yellow",
    
        "Network C","Grey")

    Then you can create a column chart and place it like this, then set the conditional format for the data color using lkalawski’s solution, like this:

     

     

    And you can get what you want.

    You can download my test pbix file here

     

    If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

    How to Get Your Question Answered Quickly 

     

    Best Regards,

    Community Support Team _Robert Qin

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