Search code examples
reporting-servicescolorslegendstacked-bar-chart

MS Reporting Services stacked bar chart with custom series fill color shows wrong legend colors


I have a SSRS stacked bar chart with Regions (on the x axis) as category and Countries as a Serie. I have a property from the Dataset called "Fields!ReportColor.Value" which I used in the formula to set the Series fill color. This formula is working fine for the color of the stacked bars, but it seems not working to set the color of the corresponding legends: in particular the right color is applied only to the legend corresponding to the first serie (the first country), all the subsequent values of the series (the other countries) are wrong.

(https://i.sstatic.net/8wpvB.png) [results:] (https://i.sstatic.net/WT0Qu.png)

As a form of debugging I used a conditional expression that returns the Fields!ReportColor.Value if this is not null and the color "Red" if this value is null: what I noticed is that while for the bars the right color is still applied, for the legends that are not corresponding to the first country the color "Red" is applied; it seems that the formula is receiving the dataset values only for the first item, but only when it is used to format the Legend color. Is there anything that I am missing here? Thanks.


Solution

  • I've tried to reproduce the problem but it works as expected for me.

    Here's the steps I took.

    Created some test data. This is the dataset query

    DECLARE @t TABLE(Continent varchar(50), Country varchar(50), x int, Colour varchar(30))
    
    INSERT INTO @t VALUES 
    ('West Europe', 'UK', 10, '#335070'),
    ('West Europe', 'France', 8, '#FF0000'),
    ('West Europe', 'Germany', 9, '#00FF00'),
    ('West Europe', 'Italy', 2, '#0000FF'),
    ('West Europe', 'Spain', 6, '#DDDDDD'),
    ('North America', 'USA', 7, '#AABBCC'),
    ('North America', 'Canada', 1, '#00CCDD'),
    ('East Europe', 'Poland', 3, '#523456'),
    ('East Europe', 'Romainia', 9, '#998877')
    
    SELECT * FROM @t
    

    Added a stacked column chart, added a category group for 'Continent' and a Series Group for 'Country'. Set the values to 'x'

    I then set the data labels to be 'country' so I could check the results.

    The design looked like this.

    enter image description here

    I then set the Series Property Fill Color property to Fields!Colour.Value.

    The final output looks like this...

    enter image description here

    As you can see the colours match both the legend and columns.