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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Testy
Helper I
Helper I

Line chart: Many color for the same line

Hello everyone,

I’d like to know if any of you have found a way to change the color of a line chart based on its values.

 

Here a picutre of what I'm trying to achieve:

Testy_0-1728547548565.png

The color change depending of the value
Higer than 3, it should be green
Between 3 and 2.5 yellow
Between 2.5  and 2 orange
And lower than 2 red

Any idea of how can I achieve that?

Many thanks in advance for your help 🙂

 

2 ACCEPTED SOLUTIONS
SamWiseOwl
Super User
Super User

Hi @Testy 

The quick solution is:
Create a column chart of your visual.

Make a new measure with your conditions:

Colour Measure =
SWITCH(
    TRUE()
    ,sum(Sales[Quantity]) > 1500 , "Green"
    ,sum(Sales[Quantity]) > 1000 , "Yellow"
    ,"Red"
)
Assign this to your Column's colour.
SamWiseOwl_2-1728548078347.png

 

SamWiseOwl_1-1728548034192.png

 

Convert that column chart into a line chart.
SamWiseOwl_0-1728548015824.png

 

Hope this helps!

 

The other option is create three seperate measure to show the lines and format them different colurs.

Only issue with that is getting the lines continius

SamWiseOwl_0-1728548659041.png

 


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

Kedar_Pande
Super User
Super User

Create a New Measure for Each Color Band

GreenValues = IF( [YourMeasure] > 3, [YourMeasure], BLANK() )
YellowValues = IF( [YourMeasure] <= 3 && [YourMeasure] > 2.5, [YourMeasure], BLANK() )

Similarly create for others....

Drag each of the newly created measures on Y axis. In the Visualizations Pane, go to Format.
Under Data Colors, assign green to GreenValues, yellow to YellowValues, orange to OrangeValues, and red to RedValues.

 

Kedar_Pande_0-1728548997922.png

If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

View solution in original post

3 REPLIES 3
v-xinruzhu-msft
Community Support
Community Support

Hi @Testy 

Did the solution @Kedar_Pande  and @SamWiseOwl  offered help you solve the problm, if they helps, you can consider to accept them as solutions so that more user can refet to.

 

Best Regards!

Yolo Zhu

 

Kedar_Pande
Super User
Super User

Create a New Measure for Each Color Band

GreenValues = IF( [YourMeasure] > 3, [YourMeasure], BLANK() )
YellowValues = IF( [YourMeasure] <= 3 && [YourMeasure] > 2.5, [YourMeasure], BLANK() )

Similarly create for others....

Drag each of the newly created measures on Y axis. In the Visualizations Pane, go to Format.
Under Data Colors, assign green to GreenValues, yellow to YellowValues, orange to OrangeValues, and red to RedValues.

 

Kedar_Pande_0-1728548997922.png

If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

SamWiseOwl
Super User
Super User

Hi @Testy 

The quick solution is:
Create a column chart of your visual.

Make a new measure with your conditions:

Colour Measure =
SWITCH(
    TRUE()
    ,sum(Sales[Quantity]) > 1500 , "Green"
    ,sum(Sales[Quantity]) > 1000 , "Yellow"
    ,"Red"
)
Assign this to your Column's colour.
SamWiseOwl_2-1728548078347.png

 

SamWiseOwl_1-1728548034192.png

 

Convert that column chart into a line chart.
SamWiseOwl_0-1728548015824.png

 

Hope this helps!

 

The other option is create three seperate measure to show the lines and format them different colurs.

Only issue with that is getting the lines continius

SamWiseOwl_0-1728548659041.png

 


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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