cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mahi1827
Resolver I
Resolver I

How to apply conditional color formatting in line chart based on fields from legend

Hi,

 

We have a "date","Product type"  as slicers, also we have a linechart; in x axis we have "monthyear", y axis "budget" and legend as "Product type info.Here we have multiple product types are assigned to one group, so some of the data in slicer we have like Product B1,B2 and product D1,D2 like that . As per requirement when i place product type as legend in line chart below is the sample data looks like in line chart with legend.

 

1.png

I have tried to apply color condtional formatting based on legend like

If product A then line chart should show budget data as red color, if its multiple product types like Product B1 and B2 then line chart should show budget in blue color, if product type like Product C then line chart should show budget data as green color and finally if its multiple product types like Product D1 and D2 then line chart should show as Yellow color.

 

Here based on slicer selection data product type data will change. As line chart currently not supporting conditionl formatting, we are tried below methods to achive expected results but conditional color formatting is not working as expected.

 

1) Added line chart without legend as one visual and created separate barchart as custom legend for products A,B,C,D and used below measure for formating in custom legend and finally combined both charts as one visual to show as line chart display.

2) Added conditional formatting in bar chart as below and applied field value formatting by measure and later it converted to line chart

 

Measure=switch(true(),max(producttype)="A" || values(producttype)="A","red",
max(producttype)="B", || values(producttype)="B","blue",
max(producttype)="C",|| values(producttype)="C","green",
max(producttype)="D",|| values(producttype)="D","yellow",
"")


In above cases, child or multiple product types appear based on data so based on "slicer selection and also as per legend" all product types colors should change dynamically for budget data.


Please let me know your suggestions and possible solutions to achive the expected results for applying conditional color formatting in line chart based on fields from legend and also displaying legend in line chart.

 

Thanks for your help in advance.

 

Thank you,
Mahi

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @Mahi1827 

 

You could customize the data color in the data color property, and you can turn on the series label

vangzhengmsft_0-1635316584483.png

vangzhengmsft_1-1635316659061.png

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

 

View solution in original post

2 REPLIES 2
v-angzheng-msft
Community Support
Community Support

Hi, @Mahi1827 

 

You could customize the data color in the data color property, and you can turn on the series label

vangzhengmsft_0-1635316584483.png

vangzhengmsft_1-1635316659061.png

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

 

lbendlin
Super User
Super User

multiple lines = automatically means you need multiple independent columns or measures. They can then have their individual colors.

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors