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
Jeremy19
Helper III
Helper III

Line chart with different colours

Hi,

It is possible to have a line that changes color according to a categorical variable? I have 3 columns (Time, Value and TeamId). I wish to have the line which is the color of the team at this time. The problem is that when I put TeamId in legend it creates two curves, one for each team like the image below

Jeremy19_0-1603489373750.png

Any ideas ?

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @Jeremy19 ,

Currently Power BI does not support this feature, you can raise a new idea and add your comments there to make this feature coming sooner. Or you can refer the solution in the following thread as workaround.

Line Chart: Conditional Formatting

Best Regards
Rena
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Jeremy19
Helper III
Helper III

Nice tip but it doesn't give exactly what I want. It displays the markers that I cannot remove and the curve remains only blue. In fact, the line should keep the color of the previous point.

mahoneypat
Employee
Employee

You can make a measure like this that you can use as the data color.

 

Line Color = SWITCH(MIN(Table[TeamID]), "Team A", "Red", "Team B", "Blue", "Black")

 

Then here's the trick that Reid Havens has a video about here - https://www.youtube.com/watch?v=2_2rGxA6PKQ

 

First make it a bar chart, use this measure in the fx button for the data color, then switch the chart to a line chart.  The line chart by default doesn't have the option to use a color measure but this is a workaround.

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.