I use MS Report Services 2016 chart control with expression for series fill color:
=iif(Fields!Date.Value = Last(Fields!Date.Value, "dataset"), "red", "green")
So all bars are green except last one - it is red. Legend also shows this series with green fill color.
Everything is ok except the case when i have only one bar, which is obviously also last one - in this case legend marker become red.
Is there a way to make legend always green?
Test how many series you have. If only 1 series then set the colour appropriately.
You can test the number of series by counting how many distinct values you have in the field that your series groups on like this...
=COUNTDISTINCT(Fields!MySeriesGroupField.Value, "Mydatasetname")
So you final expression might look something like this.
=IIF(
Fields!Date.Value = Last(Fields!Date.Value, "dataset")
AND COUNTDISTINCT(Fields!MySeriesGroupField.Value, "Mydatasetname")>1
, "red", "green"
)