cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Peter_Jeyaraj_I
Helper I
Helper I

Color Change in Line Chart based on Slicer Value

Hi Team, 

 

Here, the requirement is to change the color of line or somehow we need to differentiate in color in line chart by using the numeric slicer value. 

Expecting an output like below. 

pic1.PNG

 

Now, I achieved above by hard coding the dax value instead of dynamic selection based on week number n above slicer. 

Dax formula ( calculated column ) = 

IF ((FE_DDSCALLRATE[Der_Deliver_YYYYQ_No]) > 20182,"OutofWarranty","Warranty")
My table will look like below..
Deliver Quarter Operating week
2018-1                   1
2018-2                   2
etc.... ,  Please help me to achieve this dynamically. Also, see below challenges while exploring all the options in power bi. 
1.  Conditional formatting will not work in the Line chart. 
2.  Legend will not accept Measure, so we need to create a calculated column to split the line by using a legend
 
Please let me know if you need any more inputs from my end. 
 
 
 
2 REPLIES 2
dax
Community Support
Community Support

Hi Peter_Jeyaraj_l

As I know, for line chart, you need to use static legend value to change the line color, so workaround are like below

You could create two meausres for line chart based on slicer value like below

more than max = var  maxselcet=CALCULATE(MAX(slicer[Date]), ALLSELECTED(slicer[Date]))  return if(MIN('table'[Date])>maxselcet,  BLANK(),SUM('table'[Column 2]))
less than max = var  maxselcet=CALCULATE(MAX(slicer[Date]), ALLSELECTED(slicer[Date]))  return if(MIN('table'[Date])>maxselcet, SUM('table'[Column 2]), BLANK())

435.PNG

Or you could create a clustered column chart, then create a measure like below

Measure = var  maxselcet=CALCULATE(MAX(slicer[Date]), ALLSELECTED(slicer[Date]))  return if(MIN('table'[Date])>maxselcet, "#50C7C7","#CCA3E3")

use this in column chart's colditional format like below, then click line chart, it will change like below

433.PNG436.PNG

Best Regards,
Zoe Zhi

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

 

 

 

Hi,

Thanks for your response. 

I tried and still see some challenges as i have all the info in same table. like below

Do i need to create any reference table to achieve the above

Deliver QuarterOperating WeeksMeasure
2018-37100
2018-48120

 

 

Regards, 

Peter I 

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors