Forum Discussion

Narukkp's avatar
Narukkp
Helper V
6 years ago

Conditional color format for legends

Hi Team,

I required the dynamic colors for legend (series). I.e. As part of our requirement  we are using the Line chart and In this chart Country as X-Axis , Year as Legend and SalesAmount as Value. Now I required Green color current year , Yellow for previous year and black color for before previous year in legend. Is it possible to give conditional color format for legends ?

 

Regards,

Naru

 

 

 

 

 

 

 

4 Replies

  • Hi Narukkp ,

     

    when you are refering to dinamic colours for legends you are abble to select the data colours on the options of the chart, however this will force the colours for each year since you have place the year on the legend so for example if you select 2020 as Green that will be it's colour always.

     

    You best option instead of using year on legend is to create 3 measures one for each of your selections cY, previous year then color your measure as you need, if you have a filter for year then this will be dinamic since the selected year will always be green and so on.

     

    • Narukkp's avatar
      Narukkp
      Helper V

      Hi,

      Thank you for your reply MFelix . If i am created the 3 measures then i am unable to see the 2020,2019,2018 values in legend. I need to show the Year column in legend . One more option in data color if i am selecting green for 2020 then next year also it will be static then our business scenario will go wrong. 

      so is there any another workaround. 

       

      • MFelix's avatar
        MFelix
        Super User

        Hi Narukkp ,

         

        If you use measures the legend the values will not be with the Year 2020,2019, 2018 the workaround for this is to create a dinamic text value that picks up the 3 years based on selection and then add a dot with the colors then group it with your visualization.

         

        You will need also to create tree measures for colouring dots or squares or lines to have the highliths on the legend.

         

        Check the PBIX file with an example.

         

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

    Narukkp ,

     

    I'm afraid you can only change the font color in legend field of line chart. You can submit your idea here to help power bi improve.

     

     

    Community Support Team _ Jimmy Tao

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