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
SanketBhagwat
Solution Sage
Solution Sage

Increasing and Decreasing trend color in line chart.

I want to have a dynmaic color feature for my line chart.

If the value goes up, then the line color should be green and if it goes down then it should be in red.

I have attached screenshot of my visual.

If anyone knows a way, then do please let me know.

Screenshot (109).png

 

Regards,

Sanket Bhagwat

1 ACCEPTED SOLUTION

Hi @SanketBhagwat ,

 

Based on my test, Conditional Formatting is not supported for Line chart currently,but this is at idea/feedback level alone. You could vote some submitted ideas in Power BI ideas forum as shown below :

Conditional formating on linear or area chart ?

Conditionally format line chart

Line Chart Marker Color Conditional Formatting

 

 

And based on my test, you may try the following workarounds:

 

  • Measure1:
Color In table = 
var _curr=CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=MAX('Table'[Year])))
var _last=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])-1))
return IF(_last>_curr,"Red","Green")

1. Use Stacked column chart

Stacked Column chart.PNG

2.Then copy ,paste the Stacked column visual, and change it to Line chart, the data point would change colors as well:

Line chart.gif

 

  • Measure2:
Diff = 
var _curr=CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=MAX('Table'[Year])))
var _last=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])-1))
return _curr-_last
Color for Diff = IF([Diff]>=0,"Green","Red")

3.Use Waterfall chart, data lable is value diff not the value:

Waterfall chart.PNG

4. Use Funnel chart, this charts don't support negative numbers: they're plotted on the chart as zero, so no bars are displayed for negative values. However, despite there being no colored bar, the label for a negative value is displayed on the chart.

Funnel chart.gif

 

Best Regards,
Eyelyn Qin
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

4 REPLIES 4
selimovd
Super User
Super User

Hey @SanketBhagwat ,

 

as amitchandak mentioned you cannot change the color within one value.

Even if you would split it in 2 measures be aware that at the point where the change happens you have to make sure that both values exist for both measures. Otherwise you will have a gap.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
amitchandak
Super User
Super User

@SanketBhagwat ,  You can only have color markers, that too you need to have conditional formatting in bar and then use line.

 

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

diff = [This Year]-[Last Year ]

 

 

then create a measure

if([Diff] >0, "Green", "Red")

use this measure in conditional formatting using field value option 

 

How to do conditional formatting by measure and apply it on pie?: https://youtu.be/RqBb5eBf_I4

@selimovd @amitchandak 

Then how do you show increasing or decreasing trend?

Is KPI Indicator the only way to show the same?

And if Power BI doesn't offer such functionality, do you guys think that it should be posted as an idea?

 

Regards,

Sanket Bhagwat

 

Hi @SanketBhagwat ,

 

Based on my test, Conditional Formatting is not supported for Line chart currently,but this is at idea/feedback level alone. You could vote some submitted ideas in Power BI ideas forum as shown below :

Conditional formating on linear or area chart ?

Conditionally format line chart

Line Chart Marker Color Conditional Formatting

 

 

And based on my test, you may try the following workarounds:

 

  • Measure1:
Color In table = 
var _curr=CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=MAX('Table'[Year])))
var _last=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])-1))
return IF(_last>_curr,"Red","Green")

1. Use Stacked column chart

Stacked Column chart.PNG

2.Then copy ,paste the Stacked column visual, and change it to Line chart, the data point would change colors as well:

Line chart.gif

 

  • Measure2:
Diff = 
var _curr=CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Year]=MAX('Table'[Year])))
var _last=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])-1))
return _curr-_last
Color for Diff = IF([Diff]>=0,"Green","Red")

3.Use Waterfall chart, data lable is value diff not the value:

Waterfall chart.PNG

4. Use Funnel chart, this charts don't support negative numbers: they're plotted on the chart as zero, so no bars are displayed for negative values. However, despite there being no colored bar, the label for a negative value is displayed on the chart.

Funnel chart.gif

 

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

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.