Forum Discussion
Conditional Format Bars and Line in a combo chart by year
Thanks for the reply from PhilipTreacy , please allow me to provide another insight:
Hi MWC914 ,
I created some data:
As far as I know, Line Chart and Clustered Column Chart doesn't support customizing the color of Line y-axis, this is due to the design of Power BI, you can use the following method instead: multiple measures are created, and each measure only displays the data corresponding to the year, otherwise it is empty.
Here are the steps you can follow:
1. Create measure.
2023year =
var _mindate=MINX(FILTER(ALL('Table'),YEAR('Table'[Date])=2023),[Date])-1
var _maxdate=MAXX(FILTER(ALL('Table'),YEAR('Table'[Date])=2023),[Date])
return
IF(
MAX('Table'[Date])>=_mindate&&MAX('Table'[Date])<=_maxdate,SUM('Table'[VALUE2]),BLANK())2024year =
var _mindate=MINX(FILTER(ALL('Table'),YEAR('Table'[Date])=2024),[Date])-1
var _maxdate=MAXX(FILTER(ALL('Table'),YEAR('Table'[Date])=2024),[Date])
return
IF(
MAX('Table'[Date])>=_mindate&&MAX('Table'[Date])<=_maxdate,SUM('Table'[VALUE2]),BLANK())
2. Lines - Apply settings to (select specified measure name) - Color (set different color).
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thank you very much, that's a very clever workaround!
Do you know if there is a way to certain items from the legend? I just looked and did not see that as an option. I could always insert a text box but would prefer to have a more automated solution.