The image below depicts the defect/result. Note the "Pass" series group on the graph is (correctly) represented by Green, but on the legend, the "Pass" series group is incorrecty represented by Blue.
If John also had a passing score, or Richard were ordered last, the above legend would render correctly. The legend would also render correctly if I used auto-color assignments, rather than a custom fill expression.
Here's the chart's basic configuration:
Here's the expression for the value fill color:
=SWITCH(
Fields!F2.Value = "Pass", "Green",
Fields!F2.Value = "Fail", "Red",
true, "Blue"
)
Here's the source data file, "sample.csv":
John, Fail
Richard, Pass
Richard, Fail
Here's the report definition:
<?xml version="1.0" encoding="utf-8"?><Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily"><df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily><AutoRefresh>0</AutoRefresh><DataSources><DataSource Name="SampleData"><ConnectionProperties><DataProvider>OLEDB</DataProvider><ConnectString>Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties="text;HDR=No;FMT=Delimited"</ConnectString></ConnectionProperties><rd:SecurityType>DataBase</rd:SecurityType><rd:DataSourceID>2a7bf909-ea4e-41ad-945b-572dd733cb1c</rd:DataSourceID></DataSource></DataSources><DataSets><DataSet Name="SampleDataSet"><Query><DataSourceName>SampleData</DataSourceName><CommandText>select * from sample.csv</CommandText><rd:UseGenericDesigner>true</rd:UseGenericDesigner></Query><Fields><Field Name="F1"><DataField>F1</DataField><rd:TypeName>System.String</rd:TypeName></Field><Field Name="F2"><DataField>F2</DataField><rd:TypeName>System.String</rd:TypeName></Field></Fields></DataSet></DataSets><ReportSections><ReportSection><Body><ReportItems><Chart Name="ExampleChart"><ChartCategoryHierarchy><ChartMembers><ChartMember><Group Name="DataBar1_CategoryGroup"><GroupExpressions><GroupExpression>=Fields!F1.Value</GroupExpression></GroupExpressions></Group><SortExpressions><SortExpression><Value>=Fields!F1.Value</Value></SortExpression></SortExpressions><Label>=Fields!F1.Value</Label></ChartMember></ChartMembers></ChartCategoryHierarchy><ChartSeriesHierarchy><ChartMembers><ChartMember><Group Name="DataBar1_SeriesGroup"><GroupExpressions><GroupExpression>=Fields!F2.Value</GroupExpression></GroupExpressions></Group><SortExpressions><SortExpression><Value>=Fields!F2.Value</Value></SortExpression></SortExpressions><Label>=Fields!F2.Value</Label></ChartMember></ChartMembers></ChartSeriesHierarchy><ChartData><ChartSeriesCollection><ChartSeries Name="F2"><ChartDataPoints><ChartDataPoint><ChartDataPointValues><Y>=Count(Fields!F2.Value)</Y></ChartDataPointValues><ChartDataLabel><Style /></ChartDataLabel><Style><Color>=SWITCH(
Fields!F2.Value = "Pass", "Green",
Fields!F2.Value = "Fail", "Red",
true, "Blue"
)</Color></Style><ChartMarker><Style /></ChartMarker><DataElementOutput>Output</DataElementOutput></ChartDataPoint></ChartDataPoints><Type>Bar</Type><Subtype>Stacked</Subtype><Style /><ValueAxisName>Primary</ValueAxisName><CategoryAxisName>Primary</CategoryAxisName><ChartSmartLabel><CalloutLineColor>Black</CalloutLineColor><MinMovingDistance>0pt</MinMovingDistance></ChartSmartLabel></ChartSeries></ChartSeriesCollection></ChartData><ChartAreas><ChartArea Name="Default"><Style><BackgroundColor>#00ffffff</BackgroundColor><BackgroundGradientType>None</BackgroundGradientType></Style></ChartArea></ChartAreas><ChartLegends><ChartLegend Name="Default"><Style><BackgroundGradientType>None</BackgroundGradientType><FontSize>8pt</FontSize></Style><ChartLegendTitle><Caption /><Style><FontSize>8pt</FontSize><FontWeight>Bold</FontWeight><TextAlign>Center</TextAlign></Style></ChartLegendTitle><HeaderSeparatorColor>Black</HeaderSeparatorColor><ColumnSeparatorColor>Black</ColumnSeparatorColor></ChartLegend></ChartLegends><Palette>BrightPastel</Palette><DataSetName>SampleDataSet</DataSetName><Height>2.21403in</Height><Width>3.30208in</Width><Style><Border><Color>LightGrey</Color><Style>Solid</Style></Border><BackgroundColor>White</BackgroundColor><BackgroundGradientType>None</BackgroundGradientType></Style></Chart></ReportItems><Height>2.21403in</Height><Style /></Body><Width>3.30208in</Width><Page><LeftMargin>1in</LeftMargin><RightMargin>1in</RightMargin><TopMargin>1in</TopMargin><BottomMargin>1in</BottomMargin><Style /></Page></ReportSection></ReportSections><ReportParametersLayout><GridLayoutDefinition><NumberOfColumns>4</NumberOfColumns><NumberOfRows>1</NumberOfRows></GridLayoutDefinition></ReportParametersLayout><Language>en-US</Language><ConsumeContainerWhitespace>true</ConsumeContainerWhitespace><rd:ReportUnitType>Inch</rd:ReportUnitType><rd:ReportID>03007dde-b4ce-4734-91b3-c6a45e1a0970</rd:ReportID></Report>
Note that I asked a
similar question a few months ago that received a non-working solution because I hadn't been clear enough.