1
votes

I am using SSRS 2014 and I have a requirement to make the max value for the y-axis scale of a chart always be at least 100. That is, if the none of the data in this horizontal bar chart reaches 100, my scale will still go to 100. However, if it exceeds 100, the max should be, well, Auto.

3D Stacked Bar Chart in SSRS

I can easily set the chart scale's Maximum property to 100, like shown in the chart above. Of course when my data exceeds 100, it gets truncated. So I thought about making the Maximum property an expression, where I decide if the Max bar height is greater than 100, set Maximum to Auto, otherwise, set it to 100. Only, I can't figure out how to get the "Max bar height" in an expression.

=IIF(MAX(Fields!CompletedWork.Value, "Chart3_CategoryGroup") > 100, "Auto", 100)

This does not work for me. Chart3_CategoryGroup is the name of the category group in the stacked bar chart. I get the error that the scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a dataset.

I am using a stacked bar chart and so my source data for this chart appears as:

Person   | Work Item Type  |  # of Hours
----------------------------------------
Person A | Development     | 10
Person A | Administration  | 2
Person B | Development     | 8
Person B | Deployment      | 4
Person C | Testing         | 3

And so forth. Therefore my chart's series group is the Work Item Type, the Category group is the Person, and the Values are [Sum(# of Hours)]. The above IIF expression does not work if I use the series group in place of the category group either.

1

1 Answers

1
votes

You need to change the expression as follows:

=IIF(MAX(SUM(Fields!CompletedWork.Value, "Chart3_CategoryGroup")) > 100, "Auto", 100)

Here we are summing the CompletedWork value within the group, then finding the max value from the groups.