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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors