I have encountered a really weird bug?? in SSRS as I try to implement a line chart with only the last data label. The chart displays predictive linear regression measures and I have implemented a custom code function in the code-behind that determines the color of the "predictive" line (based upon a lookupset which determines if the trend is up or down). I want to have conditional logic that so that only the last point on the line is shown in the label which is usually not a big problem but this time I'm running into issues. As soon as I call the custom code function to determine line color, the last point on my line shows the second last point's field value. If staticly set the line to have a color of "Red", then the last point has it's own field value as the data label.
This would be much easier to explain if I could post my screenshots, but I'll try to layout a scenario if clarification is needed:
Scenario 1) Line color determined in code-behind
Formulas in report:
Line data label: Trim(Fields!Month.Value)
Category label: Trim(Fields!Month.Value)
Line color: Code.TrendDirection(LookupSet(1, Fields!Lookup.Value, Fields!MonthTrend.Value, "FacilityTrends"))
Values for last data point:
Line data label: Mar-2014
Category label: Apr-2014
Line color: Red (as properly determined by code behind)
Scenario 2) Line color set statically
Formulas in report:
Line data label: Trim(Fields!Month.Value)
Category label: Trim(Fields!Month.Value)
Line color: "Red"
Values for last data point:
Line data label: Apr-2014
Category label: Apr-2014
Line color: Red
Why would the custom code expression for line color affect the field value of the last line data point? Any ideas?
Related
I have a matrix in my SSRS 2016 reporting services report. I am trying to set a conditional expression on background color for the sum(field.value). This field is formatted as a percent. Here is my expression which does not appear to have any errors:
Background Color Expression:
=Switch(Fields!PicturesbeforeFirstSignoutCount.Value<.80,"Red",Fields!PicturesbeforeFirstSignoutCount.Value >= .80 and Fields!PicturesbeforeFirstSignoutCount.Value < .95,"Yellow",Fields!PicturesbeforeFirstSignoutCount.Value >= .95,"lightGreen")
Problem: It turns everything "lightgreen" even when their textbox should be yellow's and red's in the matrix. there is one field that is highlighted as Red, but it should have been Yellow.
I tried to set this in the field property for background color expression. That just made everything "light green".
I changed it to the fill expression in the matrix Text box. Now I get mostly everything green except the one red field that should be yellow. I checked my numeric values and they are coming across in decimals points when I change the format back to number
Any help would be appreciated.
As Harry mentioned in the comments, you need to be evaluating the same expression as you are displaying.
Also you can simplify the SWITCH statement as follows.
=SWITCH(
SUM(Fields!PicturesbeforeFirstSignoutCount.Value) <.80, "Red",
SUM(Fields!PicturesbeforeFirstSignoutCount.Value) < 0.95, "Yellow",
True ,"LightGreen"
)
As SWITCH returns the first result where the expression is true, there is no need to put a range in. so if the value was 0.91 then the first expression would be skipped but the second one would be true to it would return "Yellow".
The final True acts as an "else".
I'm using Report Builder 3.0. Long story short, I want to make the font bold for the text in the red box that you see in the image below:
Basically, it's just one expression in the legend field of my value, however, for clarity's sake (for my end users) I wish to make the "title part" bold. I found the following solution for textboxes in a tablix using Html by checking off the "HTML – Interpret HTML tags as styles." checkbox within the Textbox's properties. (http://www.sqlchick.com/entries/2010/10/31/using-different-formats-within-a-single-textbox-in-ssrs.html)
However, I can't find anything similar for graphs! I mean if MS thought about it for tables, I presume they must've given it some thought for a chart setting too.
Thanks to all!
p.s. As an aesthetic solution to my problem, I did think of simply creating a new title field, moving it to the exact same location and formating it. But I'm surious whether there'd be some more "proper" way of doing this.
I'm using the same approach for one of my charts.
STEPS.
Select the Chart series to open property pane. In my case, the chart series name is TWR Chart Series
Select the color property and select to build the expression.
I'm posting one of my expression. You can build your own expression base don your field names etc.
=IIF(Fields!ProductID.Value = 1 OR Fields!ProductID.Value = 6,"#00425E",
IIF(Fields!ProductID.Value = 3 ,"#6B8797",
IIF(Fields!ProductID.Value = 5 OR Fields!ProductID.Value = 7,"#799179",
IIF(Fields!ProductID.Value = 4 AND Fields!sort.Value=99,"#6bb1be","#48597B"))))
If used sensibly, you should get your desired results.Good luck.
I have an SSRS Line chart which plots supply points with square feet on the X axis and Price on the Y axis. Right now I don't really care about making it pretty just getting the lines to show up correctly. I am plotting the points and grouping by Subdivision/Builder.
So for example Subdivision A has builders Y and Z. I want to show different colors and lines for Subdivision A builder Y verses Subdivision A Builder Z.
The problem is that the lines are not connecting when a point for another subdivision builder combination breaks up that line.
The grey line and points below are not all connected as the yellow point is between the grey points so the grey line is not connected to all grey points.
How can I make the points of the same color (same Subdivision/Builder) connected via a line?
As I found out the hard way recently, this problem is often caused by null values in the data not being properly handled by SSRS. Without seeing your data, I can't be certain that's the cause, but nulls were the culprit I encountered the same behavior.
The solutions usually involve assigning values to the color of the EmptyPoint property on the Series, sometimes in conjunction with setting the EmptyPointValue to specify null handling. I've found many references to this problem on the web, but I'll only post links to the best two, both of which are on StackExchange:
The thread SSRS Line Chart NULL VALUE - Horizontal Line contains a thorough discussion of this issue. The usual workaround given is to hard-code a color expression for each line using an IIf, but sometimes this isn't an option, especially if the field you're grouping on has dynamic, unpredictable values, as my dataset did.
The picture posted there depicts clear examples of the same type of line breaks. The user named trubs posted a code sample which illustrates how to set the EmptyPoint, in case where an Iif will work:
=iif(isNothing(Fields!SelectedValue.Value),'No Color',"LightBlue")
The first reply in SSRS Line Chart Not Connecting Data Points details a workaround for cases when the EmptyPoint value & nulls are the root cause and simple hard-coded IIfs won't do the trick. Although I have yet to get my line colors to match the point markers the way I'd like, I can verify that this solution at least gives you your lines back and allows you to assign a variety of colors to them. It's fairly simple and involves merely pasting in some VB code for a couple color properties.
I was asked in the comments section to provide the details of the solutions, but don't want to plagiarize, so I'll simply do a long direct quote of JohnBob's answer:
Firstly, in order to get the lines to join up, you need to set the
EmptyPoint colour for the series.
Select your series in your chart In the properties tab (not the
dialog) drill down into the EmptyPoint property and set the colour to
be Black
This will get them joining up - yay! But part of the line is colour
and the other part is black, right? That's a bit silly, especially
considering if you leave the colour to Automatic on the EmptyPoint
that it will be transparent.
So, then we need to get the series and the EmptyPoint's colours in
sync. Using code from here. I added some code to the code of the
report.
1). Right click on an empty space on the report and select "Report
Properties" 2). In the code tab, paste the following:
Private colorPalette As String() = {"#418CF0", "#FCB441", "#E0400A", "#05642E", "#1A3B69", "#BFBFBF", "#E0400A", "#FCB441", "DarkBlue", "Tomato", "Orange", "CornflowerBlue", "Gold", "Red", "Green", "LightBlue", "Lime", "Maroon", "LightSteelBlue", "Tan", "Silver"}
Private count As Integer = 0
Private mapping As New System.Collections.Hashtable()
Public Function GetColor(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colorPalette(count Mod colorPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
Then we need to call this code when setting the colour of the series
and of the EmptyPoint.
Select your series
In the properties tab paste something the following (replace WhateverTheGroupIsForYourSeries with your series group name):
=Code.GetColor(Fields!*WhateverTheGroupIsForYourSeries*.Value)
Drill down to the color element of the EmptyPoint Series property
Paste the same text as from point two [e.g. =Code.GetColor(Fields!*WhateverTheGroupIsForYourSeries*.Value)]
And voila! You're done! I can't believe how unnecessarily difficult
this is :D
I hope this helps.
Just put your Fields!(YourSeriesGroup).Value in Series Groups to above of
Fields!(YourCategoryGroup).Value in Category Groups, your series group should be in both Series Groups and Category Groups (should be above of your initial category group).
And after that right click horizontal axis and select Horizontal Axis Properties. Set Axis Type to Scalar and click OK.
I'm using Octaves "bar" command to plot a grouped bar graph based on data loded from a matrix stored in an external file. A similar plot based on random data can be created using this command:
bar(rand(4, 6));
I'd like to create a legend explaning the 6 bar colors occurring in each group instead of a legend for the 4 bar groups themselves. Executing the command
legend({"Probe 1", "Probe 2", "Probe 3", "Probe 4", "Probe 5", "Probe 6"});
creates the legend labels but does not assign the bar colors. Is there a way to fix this?
According to the Octave legend documentation, specifically examples 18 and 19, you should get what you are looking for with either legend('Probe 1', 'Probe 2', ...); or with legend({'Probe 1', 'Probe 2', ...});. Maybe try changing your quotations to single-quotes.
You can also get a handle to your bar graph with:
b = bar(rand(4, 6));
And then plot the legend with color boxes with:
legend(b, 'probe 1', 'probe 2', ...);
Edit: I tested each of the above methods and they all produced the legend that I believe you are looking for. The result looked slightly different than the figure here (made with MATLAB), but functionally the same. Oddly enough, so did your syntax (with double quotes instead of single). Are you plotting the figure in X11? Or are you plotting anything on top of the bar chart before generating the legend? Passing the handle to the bar chart should solve the latter case.
I have data that I need to present in both a bar and line chart as one this how the chart is laid out in SSRS:
Series Group: Location
Category Group: Year
Category Group: Month
Values (Y Axis): Site_count (Bar chart)
Values (Y Axis):Network_count (Line chart)
My issue is that the Correspondences_count for both of these are being grouped by location. I need to prevent the line chart one being added to the location grouping, so that way it shows a single line.
I found this, that seems to show how this might be able to be done.. . however its not working for me: http://social.msdn.microsoft.com/Forums/en-US/74d9affc-ebf3-485c-988e-f28f7049b600/how-to-make-one-of-the-chart-ignore-series-grouping
Any help is as always appreciated.
The process described in that link should be OK.
Say I have some sample data:
And a simple chart that has the same issue you're describing:
Under the Network_count Chart Series properties, change the Value field expression to:
=Sum(Fields!Network_count.Value, "Month_CategoryGroup")
Here, Month_CategoryGroup is the name of a Category Group:
Now the Network_count value is the total for all Locations:
You'll note I've removed Network_count from the Legend:
This was displaying incorrectly so I just removed it. If you still want a Legend, the easiest thing would be to create something with a tablix/textboxes outside of the chart.