Different color chart - reporting-services

I have 2 kinds of charts,pie chart and column chart.
I present the same data of both charts, the problem is that color that presents each equipment is not the same in both of them.
Thanks

The chart legend uses color fields to match the legend items to the
visible data points. The legend can only show one color field per
legend item (data series); hence, it shows the color of the first data
point within that series. Remember this when you use expressions to
dynamically determine the color of individual data points within a
series; the legend item always shows the actual color of the first
data point.
Using the same legend order in both charts should do the trick.
Series are ordered in the legend according to the order that they are
processed by the Reporting Services processing engine. You can change
the order by changing the order of fields in the data fields
drop-zone. If you are using series grouping, the series data is not
known until processing, so that there is no way for you to re-order
these items.
If you're using series, which you probably are, you should make sure they're ordered correctly before sending them to the reporter.
Another solution is to create a custom legend for your charts. Which gives you a lot more control, especially if you define a custom color palette aswell.
You can get more flexibility and control over the legend by generating
your own custom legend by using a table or a matrix. The easiest way
to synchronize the colors in the chart with your custom legend is to
define your own custom chart color palette.
To build a custom legend
Add a table data region to the report.
Place the table next to the chart and bind it to the same dataset as the chart.
Mirror the chart grouping structure in the table by adding table
groups.
If the chart uses series groupings, add them to the table by
adding table groups that are based on the same group expression as
the one in the chart series groupings. Then add chart category
groupings (if present) as inner table groups.
In general, if the
chart has m series grouping and n category grouping, you add m+n
table groups for your custom legend.
For the individual table
groups, make sure to show only the group header (which will contain
the legend description). Also, remove the table detail row unless
you want to use the table detail rows to simulate a chart data
table.
Design the custom legend.
Add a rectangle for the color field of the
custom legend. For example, you might add it to the first table
column. As indicated in step 2, you should only have group header
rows in the table. The rectangle goes into the innermost group
header level.
Set the rectangle BackgroundColor property to the equivalent expression used on the chart data point's fill color. In the most
trivial case, the expression would just contain one grouping value as
in the following code.
=Code.GetColor(Fields!Country.Value)
For the legend text, use either the same expression as in the category and series group/label expressions, or experiment until you
achieve the legend description text that you want.
Sources:
Get More Out of SQL Server Reporting Services Charts
Formatting the Legend on a Chart

Related

Filter in TextBox Expression SSRS

I have 5 visualizations in my rdl file. After each visualization I have a ABOUT Textbox which should be filled from a database table and it has html content to render.
Consider a table with 5 rows having visualization name and ABOUT Text.
<table><tr><th>visualization Name</th><th>About Text</th><th></th><th></th><th></th></tr><tr><td>Visualization1</td><td><B>Table1</B></td><td></td><td></td><td></td></tr><tr><td>Visualization2</td><td><I>Table2</I></td><td></td><td></td><td></td></tr><tr><td>Visualization3</td><td><B>Chart1</B></td><td></td><td></td><td></td></tr><tr><td>Visualization4</td><td><I>Chart2</I></td><td></td><td></td><td></td></tr><tr><td>Visualization5</td><td><B>PieChart1</B></td><td></td><td></td><td></td></tr></table>
I have created a DataSet which would pull all 5 rows along with 2 columns. And I want to link each row's AboutText field to each TextBox of individual visualization. Of course I'll have to use filters. But there is no option for adding filters in TextBox expression. And I don't want to create 5 separate DataSets for just rendering purpose.
How would I achieve this in SSRS 2016?
Create a tablix and put your visualisation in one row and your About Text in the next row as a child group. Set the child groups visibility to be toggled on the parent group and your will be able to expand and collapse the About Text row by clicking on a little + icon that will appear next to your Visualisation.
There are a few ways you could do this. One option is to add an ID column to your dataset. Then in each textbox you can use the Lookup function to get the appropriate label. Another option is to insert a table with one cell next to each visualization. You can use the Filter property on the table to control which label is shown.

Set chart axis label for individual groups with an expression

I'm on VS2012 SSRS and trying to do a report prepared for each AgentID. The agent needs to see his bar highlighted and IDs for other agents should be hidden.
We agreed I can go with plan A putting or planB completely hiding IDs other than the selected one from horizontal label.
I've illustrated this in the picture with ID 22222.
I managed to highlight the bar with an expression on the fill property of the series. But I'm not sure how to modify the axis label individually. I think that the property for axis label refers to the label for every group. I can hide all of them, but can't manipulate them individually.
In the category group properties you can dynamically assign the axis label for the entry. This is on a value-by-value basis and only effects the labels, not the grouping. So if you have multiple labels that end up the same they won't end up grouped together.
So in your case the expression for the label would probably be something like
=IIF(Fields!AGENT_ID.Value=Parameters!AGENT_ID.Value,Fields!AGENT_ID.Value," ")
Do note: I've used a space(" ") and not just an empty string(""). Using an empty string SSRS will fill the empty categories with numbers. A space will blank out the category name.

Hide Duplicate Legend Items in SSRS Report Chart

I have a stacked column chart in SSRS that displays data by hour. Included in this data is the meters reading, kVa, Average Temperature and Heat Index for that hour. For some reason, the legend items for the temperature values and the kVa are being repeated for each meter in the dataset. I would like for my legend to have the following values: kVa, Average, Heat Index and each meter number. I included a sample of the chart, the chart data configuration as well as some sample data below. Any idea how I can accomplish this? Please let me know if any other information is required.
Here is a good solution which covers all possible scenarios
go to "Report Properties" (right click in the blank area)
go to variables and add a new variable called myflag, set the value to "true" and deselect Read-Only
go to the "Series Properties" and then to "Legend" and click the expression button next to "Do not show this series in legend"
Type or paste this code:
=IIF( Variables!myflag.Value = true, false, true )
=Variables!myflag.SetValue( false )
and that's it.
hint
You can use the same variable in the same series' visibility expression without the setting part in the second line to avoid overlapping the drawing of the same series on the chart
I couldn't get either of these answers to work for me. Ended up using RowNumber and CountRows in the expression for Do not show this series in a legend property.
=IIF(RowNumber("Dataset")=CountRows(),false,true)
You're getting one set of legend values per series you've added. For each series besides the one whose legend you want to keep visible, right click the series (each top-level row in the "Values" box), choose Series Properties, go to the Legend tab, and check "Do not show this series in a Legend."
I was able to fix my issue using information from this question on stack overflow: https://stackoverflow.com/a/1867343/965213
Go to the Legend page of the series properties you want to include in the chart.
Edit the function for the "Do not show this series in a legend" property.
Use this formula: =IIF(Fields!SerialNumber.Value=Last(Fields!SerialNumber.Value,"MeterDetail"),false,true)
Now the series will only be repeated once instead of once per series group.
Hope this helps!

SSRS 2008 - charts by groups with matrices underneath

The report user wants to have groups by business unit and within each group they want to chart a set of same 4 metrics one under another: metric1, metric2... metric4. Under each of the merticN chart they want a matrix showing metricN values in rows where the months are the columns (metricN is actually 3 metrics: current month's, YTD and previous YE which is the same for every month).
Question: I know that it is possible to use list, bound to a group, to show charts by groups. Is it possible to insert a matrix for the same group under the chart (not to the right of it)?
I tried inserting nested rectangles, but a matrix inside a nested rectangle can no longer be bound to the same dataset, needless to say to the group (dataset is disabled).
As a proof of concept I can build a matrix with a chart inside the proper group, which does not solve the task of putting charts above the data. The charts, even so small, look fine in design, but in preview mode SSRS plays some dirty tricks. The resulting chart (occupying 100% of the group box and leving no space for group title, of course) is very ugly - horrible combination of scaling (why?!) and being squeezed into a small area. It looks like SSRS is going mad when a chart is in a confined space. The charts are stretched vertically and horizontally, the lines are thick and fuzzy. Only those charts, that end up in a partial group at the end of the page, look OK from graphical POV.
The most scandalous part is that even though data is correctly groupped by the matrix and reflected in the axis auto-scaling ticks and legends, it is not plotted. The charts remain empty. There must be some 'advanced option' hidden somewhere that is necessary for the charts to work within a matrix, or it is simply bugged.
Edit:
The best I've done so far was adding a Total row above a group and inserting a chart into that cell. It is somewhat closer to the requirement with several drawbacks:
The chart is only above the group name, not above whole matrix
Due to p.1 the chart cannot be made large enough
The matrix's column headers are separated from matrix data by the area
height of the chart
However the chart is still not plotting data. Playing with Category/Series Groups 'Synchronize group in' property is not helping.
To have a chart per group and group data in a matrix one on top of another, one should create a list and insert the required row groups with header rows. Then make group columns except the innermost hidden, delete the detail row and insert both chart and matrix into the innermost child group.
Then put the group fields into the group header cells.
This way the group titles appear at the beginning, then the chart, then the matrix and the last two are repeated in every child group.

Is it possible to add items to legend that are not on the chart?

I have a column chart in SSRS with a single series group. The chart is perfect but I need to add a couple of items to the legend even though they are not part of the chart (don't ask). If I add them to the data source with 0 values, the width of my columns still change to reflect the new number of items in my series group.
I ended up using Word to create an image of the proper legend and using this image as my legend. Works great but feels like duct tape.