I have a simple List in my report, with a single row and a single column (which is repeated depending on the number of items returned by the query).
What I'd like to do is this: Inside the cell (in the same location), display one rectangle full of items (text boxes, images, etc) for even rows, and another (with different items) for odd rows.
What is the recommended way to accomplish this?
I would use something like this for the Hidden property of the Rectangles:
=IIf(RowNumber(Nothing) Mod 2 = 0, true, false)
Use a different order for true / false for each of the two Rectangles to get them to alternate.
All the expression is doing is checking if a row number is even and setting the visibility based on this.
This is a pretty standard SSRS pattern which is typically used for alternating row colours, but it should work the same for showing/hiding items.
Related
I have a report containing a Tablix/table with sets of rows and columns which I am hiding conditionally using Expressions, via the Column/Row Visibility dialog.
If for example I have 3 columns which I want to all have the same Expression to determine their visibility, is there any way for me to achieve this without opening the Column Visibility dialog for each Column and entering the appropriate Expression?
I've tried selecting multiple columns, but then the right-click context menu no longer offers the Column Visibility option (it's greyed out) and I have also tried out the Hidden property of the columns (which can be amended in bulk by selecting multiple columns), but this only stops the columns from being rendered, leaving a blank space where they used to be (rather than how Column Visibility works, where columns to the right of the hidden columns are moved across to fill the gap, like hiding columns in an Excel sheet).
Is it possible to achieve what I'm after, or will I have to continue opening the Column/Row Visibility dialog for each column/row I wish to conditionally hide/show?
If the columns you want to control the visibility for are next to each other, you can create a Column Group for them and manage the visibility via the Group.
Add a new column group at the appropriate level so that only the relevant columns will be included.
If you already have Column Groups this will likely be a Child Group or an Adjacent Group.
If not, you can create an initial Column Group by dragging a Dataset field from the Report Data into the Groups pane.
Insert new columns inside the new group, and move the data from your existing relevant columns into the group.
The new group does not need to repeat, so in it's properties window set Group on: to a plain text value, e.g. "1".
Input the desired visibility settings into the Visibility page of the properties window.
For each of the individual columns inside the group set the Hidden property to False, to remove any other expressions or settings that might interfere.
Not exactly what you are looking for but perhaps a midway point - and this can apply to many things other than visibility (e.g. background colour, tooltip) - edit the RDL directly using View Code. This has the added benefit of being able to implement changes that are almost identical per column instead of identical with a minimum of mouse usage.
Typically I have set one column up the way I like it in the designer and then copy/paste under the other columns. In the case of visibility look for <TablixColumnHierarchy><TablixMemebers>. You will see a list of empty <TablixMember /> items along with the expanded <TablixMember><Visibility><Hidden>=... block where you have set up one column. Simply copy paste that block over the empty items at the position of interest (you will need to count it out unfortunately as there are no identifiers).
Bonus Tip: If you make a mistake or want to change something later, you can do a replace on all expressions at once (optional regex allowed).
Remember to backup or check in your work first because the designer may not open that report again correctly if you make a mistake :-)
Select the columns you want to conditionally hide and press F4 to see the Properties Window. Look for the Visibility node and use the Hidden property to set the conditionally expression.
The expression should evaluate to True for hiding and False for showing.
Let me know if this helps.
I have a basic Tablix in my report that currently renders as follows:
These are steps in a manufacturing process with the clock number of the person who performed them with date performed in the last two columns. However, sometimes steps are combined and performed together. In the example above, steps 10-20 are performed together, and 30-40 are performed together. So I would really like the report to be rendered like this:
I do have a column in my data called "StepRange" which in the above example would be "10-20" for the first two rows and "30-40" for the third and fourth rows. So when the value of StepRange is alike, I know those rows are performed together and henceforth the last two columns should be combined. My example shows only two rows being combined at a time, but it could be any number.
How can I make my report look like the second example above instead of the first?
Single Tablix Method
Rather than literal conditional merging, you can set the border style of a textbox using an expression to achieve a similar effect. There are a few steps, but none of them are particularly involved.
Create a parent group for StepRange. Do not add a header or footer, and delete the added column without removing the group.
Make sure that your properties panel is visible on the right of your screen. If not, check the "Properties" checkbox under the View ribbon.
Click on your first detail TextBox and expand the "BorderStyle" property. Set the "Top" property to the following expression:
=IIF(RunningValue(Field!Step.Value,CountDistinct,"StepRange")>1, "None", "Solid")
Set the Bottom property to "None".
Set the expression of the detail TextBox itself.
Replace FIELDNAME with the appropriate field:
=IIF(RunningValue(Field!Step.Value,CountDistinct,"StepRange")>1, "", Field!FIELDNAME.Value)
Repeat this process for each detail TextBox.
You may need to create a dummy row at the bottom with a black top border if you do not have a summation row. (optional)
The expression only evaluates to "Solid" for the first Step value within each StepRange group, so subsequent rows do not have a top border and appear undivided.
Nested Tablix Method
Using a nested Tablix is more straightforward. I have had some issues with them, including some rendering hiccups. But in a report this simple that may not be an issue at all.
Set up your main Tablix to group on StepRange.
Either clear or add a column to the left for the individual steps.
Select "Insert Table" from the toolbar and click on the empty cell.
Set the cells to your step and operation fields and delete the extra column.
The result should look roughly like this:
By default the inner Tablix will be detail grouped. If your detail rows are more granular than the "Step" field, go to the properties of the "(Detail)" group and add a Group Expression for Step.
You can also delete the inner header row if you don't want to see it repeated in the report.
This results in the employee fields actually being merged and spacing properly. If you don't use an aggregate function on those fields, their value will be that of the first row returned internally. Which is moot if their values are uniform across steps.
I have an SSRS report that has a cell which I need to show the value of a Dataset item unless a parameter is selected, in which case I need to display a sub-report in that cell.
I tried setting the sub-report's visibility but then it never displays the expression since it takes over the entire cell. It's like it is either one way or the other.
If you put a subreport in a cell then you can't optionally display something else in that cell.
However from your comment you're trying to display values from two different datasets based on a condition, and you should be able to do this with an expression. Assuming there is some field in the table that can be used to relate to either dataset, then you might be able to use the lookup() function to get the relevant value, e.g. a code outline for this:
Iif(some_condition, lookup(value1 in datasetA), lookup(value1 in datasetB))
I need to report "Employee Name" And "Age", but I do not need to continue the names to the next page; I need to continue it to the next column.
It should look like this :
_________________________________________________
| Employee Name | Age | Employee Name | Age |
|_______________|_____|_______________|_________|
Can anyone send an report that manages this? I am using Microsoft report service.
You want a multi-column report by the sound of it.
On the Layout tab, right-click somewhere where there aren't any report objects and choose Properties. Click on the Layout tab and set the number of columns to how many columns you want on the page - in your example it would be 2. This will give you a column to lay out report objects on the left and a greyed-out column on the right that will be where your column on the left will repeat.
However, there are a couple of tricks here:
Your columns must fit on the page or you won't get any columns. For example, if your Layout settings are at their default of 1cm spacing and 2.5cm left and right margins, then your column must be less than 7.5cm on an A4 (21cm wide) page. Otherwise you will only get one column as two columns don't fit on the page.
The report renderer in your designer doesn't support multiple columns so you will only see one column in the designer. The HTML renderer also doesn't support multiple columns and you will only see one column for the report when deployed to the reporting services server and displayed as a web page. You need to output your report to a renderer that supports multiple columns, such as PDF or a printer, in order to actually see columns in a multi-column report.
Update - faking multi-column report using tables
Failing that, to get it to display the way you want independent of renderer is to use a hack with two tables, like you tried, but the trick is to hide the rows in an alternating manner.
To implement this hack, create two tables side by side that both point to your data set. On the Detail row of the first table, for the Visibility-Hidden property use the following formula:
=iif((RowNumber(Nothing) Mod 2) = 0, True, False)
On the Detail row of the second table, for the Visibility-Hidden property use the opposite formula:
=iif((RowNumber(Nothing) Mod 2) = 1, True, False)
This means the first table will print every odd row and the second table will print every even row, effectively giving you multiple column output.
For a generic solution for visibility of the tables when wanting more than two columns, use the formula:
=iif((RowNumber(Nothing) Mod TOTALCOLUMNS) = THISCOLUMN, True, False)
where:
TOTALCOLUMNS is the total number of columns
THISCOLUMN is the column number this table represents, zero-based (i.e. first column is 0, second is 1, etc)
For example, the table for the third column in a five column output has the Visibility-Hidden property set to:
=iif((RowNumber(Nothing) Mod 5) = 2, True, False)
Note that this is slightly different output than true multiple column as it reads left-to-right rather than down the page before wrapping to the right hand column as true multi-column does. However, it has the advantage of rendering properly in every renderer.
You could adapt this method to do true multi-column by working out how many rows you can fit on the page from the InteractiveSize-Height property and displaying that many columns in the left table then the rest in the right table and so on throughout the report but this might be fragile depending on renderer and changing page layout settings like margins. The method above is simple and effective.
I am trying to do EmployeeName and EmployeeTitle. I tried to implement Chris' solution above. I would get the expected values in each table but they would be duplicated.
I did a little bit more research and I ended up with the following for row visibility.
For Even rows I used:
=iif(RunningValue(Fields!jobtitle.Value, CountDistinct, "EmployeesDataSet") Mod 2 = 0, True, False)
For Even odd rowsI used:
=iif(RunningValue(Fields!jobtitle.Value, CountDistinct, "EmployeesDataSet") Mod 2 = 1, True, False)
The rowgroup was on jobtitle.
Source: RowNumber for group in SSRS 2005
Is it possible to display dynamic number of tablix(es) in a report?
That is, if we do not know the number of tables/tablixes to be displayed in advance.
The requirement is that all the output tables will have exact same structure (row and column lables, groupings, etc.).
If you are using data from a single data source, you could achieve this result by using a single tablix, having the highest grouping on the item(s) you want to use to break up the tablix and including a page break as part of that grouping.
For now, I found a way to solve it. Created a static row within the top group and set set its RepeatOnNewPaAge=true. Remove the borders, so that it looks like a separate text above the table.
This way, it prints the latest group info at the top (because it is part of the group) and also gets displayed on every page, because it is statc. Cool huh? :-)