Dynamic matrix width to always equal chart width - reporting-services

Most things are dynamic in SSRS i.e you can create a custom expression for most formatting.
I have a report with a matrix tool. This matrix will vary in width depending on how many columns are included.
Above the matrix is a chart.
How do I make the column width dynamic so that is always the same width as the matrix?

Sorry, but it's not possible. The width of columns in a matrix can't be set with an expression:
Q: Will the width property of a column be able to be set at run-time
A: This is a common request and I definitely see the value in it. However, we didn't get to this for SSRS 2008.
Source on social.msdn
One alternative that may suit you is varying the width of the chart, because they do have a properties for Dynamic Height and Dynamic Width (see also this blogpost). Note that this only available in SSRS-2008 and up.
The other alternatives will be much "heavier", including generating (or editing) the XML for the RDL dynamically. Workarounds would inlude hiding excess columns (the visibility can be dynamically set)

Related

SSRS - Shrink report width when hiding columns

Using SSRS 2013. I am able to hide columns with boolean values, but the report (body) width does not shrink when columns are hidden. Thus, there is excess blank/white space to the right of the report. Is it possible to eliminate this excess space? If yes, kindly will you please advise how?
The report body width - as with any column width and unlike heights - is a set value that cannot be changed on execution. You need to either put up with the white space, format your presentation layer to not be affected by the appearance of the white space or redesign your report so the objective of hiding the columns can be achieved in a different way.
I ran into this exact same limitation of SSRS. I was able to achieve what I believe you are trying to get (consistent report and report col width when certain columns are hidden due to parameter vals, etc.)- by simply having 2, separately formatted report tablix/tables in the report and hiding/showing based on a parameter (or some SSRS-expressible logic):
1 for the condition when all columns are present; 1 for the condition when some columns are omitted- both of them formatted to utilize all available screen real estate to minimize white space and make things look "clean".
Instead of hiding column(s) when my hidden condition is true- I simply show the 2nd tablix and hide the 1st. And when the filter changes to show all columns, I do the reverse (hide the 2nd tablix and make the 1st visible again).
Not sure if that helps, but I figured I should share if it might aid anybody else facing this issue.
PS: Your tablix Hidden expressions will look something like this:
[the full column tablix].Hidden
=iif(Parameters!parmOmitSomeCols.Value = true, false, true)
[the tablix with some columns omitted].Hidden
=iif(Parameters!parmOmitSomeCols.Value = false, true, false)

Dynamic Width Adjustment of a Column in Tablix in SSRS

Hi everyone,
I wanted to adjust the width of a tablix column dynamically. can some one please let me know how can this be done? when i searched some forums there was a suggestion that i try creating an instance of the report in the CODE of the report properties and access the tablix column using the instance but i wasn't able to do that. Can some one please help if indeed i can try creating an instance of the report and access the tablix and adjust the width dynamically ?
Thanks,
AJ
On the off-chance that anybody is still looking for a way to have dynamic column widths in SSRS (as I was), I've found way that works for most scenarios.
Basically you add another column header to your table/matrix/tablix and set your column to your minimum required width, then add a subreport to the new header. The subreport consists of a matrix with a static row group and a dynamic column group that generates a number of fixed-size columns based on the desired width, which is passed via a parameter from the main report to the subreport.
e.g. Your main report has a column where you want to set the width from data or a parameter, which is in a range from 5 to 10cm, with increments of 1cm. Let's say for a particular column you pass down 7cm to the subreport, which then does a basic SQL loop to produce some data with 7 rows. The matrix column grouping in the subreport points to that data, which produces 7 columns, each 1cm, for a total width of 7cm (plus the row grouping which is shrunk as much as possible). The main report's column then expands to the size of the subreport, which is 7cm.
Select the first column, in properties, find the width property (under size) add an expression that uses the same condition for hiding column 3 and increasing the width of the first column, e.g.
=iif(parameters!par.value=true,"1,5cm","2,5cm")
--EDITED --
I'm very sorry my previous solution was false, I hadn't checked it, I'm sorry to have wasted your time, but I have a solution that works.
create two first columns, i.e. two columns that show the same information, one that is the width that you like when column 3 is visible (lets call that one col1a) and one that is the width that is suitable to when column 3 is hidden (col1b) and then make those two alternate. then when you hide column 3 then you also hide col1a and make col1b visible and then the other way around
There is no property to auto size the column width. Length we can do it dynamically. That is the limitation Microsoft tools.
For now, one solution is to have a reasonable fixed column width (such, as 30) and set the textbox CanGrow to True so it wraps to next line if needed. Another solution is to have two columns and hide one of them conditionally.

How to increase Chart size dynamically inside a table in ssrs

I have a range bar chart inside a table of row group and the chart is repeatedly generated according to a category. I want to increase chart height dynamically based on a category.
suppose
if category =A THEN CHART HEIGHT=10CM
if category =B THEN CHART HEIGHT=7CM
If you look in the Properties of the chart there is a field called DynamicHeight, which will, as suggested, dynamically change the height of the chart based on a value.
For example I have set a parameter called Offset to default to 8.
You can then set the value of DynamicHeight to
=CStr(Parameters!Offset.Value) + "cm"
Then, as you change the Offset parameter, the width of the chart changes.
DynamicHeight = 8
and
DynamicHeight = 4
Now how you calculate the height to be a meaningful and consistent is up to you... I get the impression you wouldn't want to use a parameter like the example above, but I'm sure it would be possible to create a calculation that will give you a sensible layout.
Update
Note it is not possible to alter the DynamicHeight on a table that is recreated multiple times in a Matrix.
I believe this is because the size of the chart area is determined to generate the layout of the report, and this area is then populated with the actual chart later in the rendering process. It doesn't know until the later stage that is should be a smaller size, so therefore is not the smaller size.

Reporting Services dynamic chart width

I have a bar chart that can display various number of bars depending on user multi-select. How do I get the bar chart to dynamically adjust to the number of bars being displayed? The only solutions I found online were dated 2008 and weren't good solutions either, surely there must be a proper way of doing this?
Thanks
While I was about to rubbish such an idea, as it is known that you cannot dynamically change table sizes and locations, it seems Reporting Services is wonderfully inconsistent.
If you look in the Properties of the chart there is a field called DynamicWidth, which will, as suggested, dynamically change the width of the chart based on a value.
For example I have set a parameter called Offset to default to 10.
You can then set the value of DynamicWidth to
=CStr(Parameters!Offset.Value) + "cm"
Then, as you change the Offset parameter, the width of the chart changes.
DynamicWidth = 10
And
DynamicWidth = 20
Now how you calculate the width to be meaningful and consistent is up to you (perhaps a permanent value for the size + (number of columns * column width)), but this should get you started.
Note that a DynamicWidth of 0 causes the report not to render.

The width of a list that contains an embedded matrix grows unexpectedly

I have a report in reporting services 2005 that includes a list with an embedded matrix and am attempting to put a border on the list, however, when I run the report in visual studio the matrix is growing past the end of the page and therefore the border is growing with it causing it to grow into the second page. It appears that there was supposedly a fix for this in reporting services 2000 service pack 1 but I am still experiencing the issue in 2005.
The list has a details group that limits the records on a row to 4 using the following expression: =ceiling(rownumber("list1")/4), the matrix has a column group that should recycle those based on the rownumber determined by the list using the following expression: =rowNumber("list1_Details_Group")
I have also attempted to put the list in a rectangle in hopes to stop the matrix from growing to no avail.
How do I effectively stop the matrix form growing past the space allowed by the list control?
I found a solution to this.... the list was initially the width of the report which cause the boarder on it to grow that amount of space between the end of the matrix inside and the end of the list. If I make the list the size of the matix that is embedded it will be the size of the matrix after it grows to accomodate the neccessay values.
In terms of the border, if you want the boarder of the list to line up with the width of the report a few things need to be done. The size of the matrix columns that grow for each row must be exact where if there are 4 columns for each row the width of the matrix column is the width of the report / 4. In addition you must always have 4 columns of data for each row in the matrix. This can be accomplshed in the query by using the % (Mod) operator and adding additional records as needed.