SSRS - How to build a simple multi-column report? - reporting-services

I am using SQL Server 2008 and I want to show 1 single field from a table in multiple columns in the report. Just like if I were to print labels. How can I achieve this?
Example:
Instead of printing:
Names Report
Andrea
Austin
Barbara
Bob
Bruno
Cathy
Chis
...
I want to print in columns (say 3 fixed columns):
Names Report
Andrea ---- Bruno ---- Darren
Austin ---- Cathy ---- Francis
Barbara ---- Chis ---- Gabriel
Bob ---- David ---- Gerald
....... ---- ....... ---- .......
Edit: If I run the report and click on "Print Layout" button, I can see multiple columns. Can I set this mode as default?

For Horizontal layout of labels...
One choice is to use the columns property on the report or body elements.
This doesn't always display correctly On reportviewer. I've noticed that even if it displays correctly on your IDE and when you export to PDF. In the report viewer it will display only one column. Also it snakes the labels top to bottom then left to right.
One choice is to use a matrix and group on every 3 rows (if you want 3 columns).
This one is a little complicated.
My solution of choice is to put 3 vertical lists on the page. put the same label in each list. Return the row number in your dataset. Then just filter each list on modulo 3
For example
Result set
RIndex Fname
1 abe
2 burt
3 fred
4 george
Filter expressions
list 1 -> =Fields!RIndex.Value mod 3 = =1
list 2 -> =Fields!RIndex.Value mod 3 = =2
list 3 -> =Fields!RIndex.Value mod 3 = =0
Result
Abe Burt Fred
George

The method I use is a bit similar as what Vern suggested but differs enough to make it worth mentioning here.
You can combine the ROW_NUMBER with the modulo (%) operator directly in the query to fabricate the column number in which the record should get displayed. Here's an example that generates one while taking a group into account:
declare #numberOfColumns int = 4;
select dpc.EnglishProductCategoryName, dp.ProductAlternateKey
, (ROW_NUMBER() OVER (
PARTITION BY dpc.EnglishProductCategoryName
ORDER BY dp.ProductAlternateKey) + #numberOfColumns - 1) % #numberOfColumns + 1
as DisplayColumn
from dbo.DimProduct dp
inner join dbo.DimProductSubcategory dps on dps.ProductSubcategoryKey = dp.ProductSubcategoryKey
inner join dbo.DimProductCategory dpc on dpc.ProductCategoryKey = dps.ProductCategoryKey;
To get this displayed I'm using nested tables which are then filtered on DisplayColumn.
Have a read through following article for all the details: Creating Multiple-Column Reports

Use the 'Report' menu in Visual Studio and select 'Report Properties'. You can set columns in the 'Layout' tab.
Try this msdn article about newsletter-style reports for more details: http://msdn.microsoft.com/en-us/library/ms159107.aspx
This method does have a limitation though so in some cases it might not be applicable:
Only PDF and Image renderers support
newsletter-style reports.
EDIT:
So one approach is to use multiple tablix with a filter that checks RowNumber and accordingly displays particular records in each table.
The other way is called Newsletter-style report (link). This formatting is retained only when report is exported as PDF or Image. It can be previewed only when you select 'Print Layout' on the Preview tab in Visual Studio. Here is an example:
Create a new report with the foll. dataset: SELECT ID,NAME FROM TABLENAME
Add a new table to the report and select the ID and Name as columns
Click on the tablix and press F4 to edit the tablix properties. In the properties window, change the Size - set the width to 2in
Click on the report area outside the report page boundary and press F4 to edit the report properties. In the properties window, change the Column value to 3, and column spacing value to 0.1
On the report scroll to the right hand side, you will notice that there are 2 new columns (so totally 3 columns on the report - because you selected 3 in step 4 above). Now click on the margin at the start of the column 2 and pull it further to the left to bring it as close to the column 1. This is only to reduce the need for huge page size.
Right click on the report area outside the report page boundary and select Report Properties. Change the Page Size - Set the width to 10in
Preview the report. Now select the 'Print Layout' tab to see the result. This formatting is retained only when report is exported as PDF or Image.
As noted in points 5 and 6 - since the report body flows into multiple columns, you must ensure that the page size is at-least equal to -> ([Original report body size times the number of columns] + all the column spacing values). Otherwise it will look messy.

Related

SSRS - Return to the line with column group

I've got a problem about SSRS design.
I need to make a report to display a list of item size.
I need to have 1 line per item with all the size of this item (and the quantity) on the same line
SSRS Design
The "Row group" have a grouping on the "Item No" field.
Actual result
Expected result
How can you put line 2 back to the beginning?
Thanks everyone for your help !
Data :
Item No
Size
Qty
1896-S
T32
4
1896-S
T34
3
1906-S
T32
2
1906-S
T34
4
1906-S
T36
5
You can do this easily with a matrix control.
Drop a Matrix control onto your report and then drag Item_No to the 'Rows' placeholder, Size to the 'Columns' placeholder and Qty to the 'Data' placeholder.
this will will give you a basic matrix, the design looks like this...
And it will look like this when rendered..
This is not quite what you wanted but we can soon change that.
All you need to do is change the expression in the 'Data' cell from [Sum(qty)] to something like this ...
=FIRST(Fields!Size.Value) & " " & Sum(Fields!Qty.Value)
Now when we render we get this...
If you want to put line breaks in etc then you can just edit the expression to suit. Alternatively you can use placeholders in the cell to have even more control of the layout and formatting.

SSRS Matrix header repeat on each page (but outside of group to show every header from ds?)

I have a Matrix which I am trying to get a specific header to repeat on each page. To keep it simple it looks something like this:
| | Months |
|Division| |
| Name | Sales |
--- new page for each division ---
If I include the [Month] columns inside the Division group, it only shows the [Months] that have activity for that [Division]. For each page (per [Division]) I want to show all active [Months] within the dataset, not just that particular [Division].
So I tried creating a new row above, OUTSIDE of the [Division] group. This worked great for the first page, but I cannot get it to repeat on each page.
Is there a way to somehow set a Matrix row as a header for each instance/page of that tablix in the report?
Or
Show every [Month] from the dataset, inside of the [Division] group, and not just the active [Months] inside the [Division]?
Hopefully that makes sense, if not I will try my hardest to explain better.
Thanks in advance!!
I found the answer here:
https://msdn.microsoft.com/en-us/library/dd207045.aspx
Under "To Display a static row or column on multiple pages"
Thanks

SSRS - Textbox Linebreak (or) Linking Table w/ Textbox

My SSRS report contains 4 tables, all of which have line breaks at the bottom.
I'm trying to find a way to tie my text boxes (titles for each table) to only show up on the first page of the start of each table. I'm honestly at a loss for this particular issue.
--Unrelated --
Originally I had a parameter with a visibility expression and a toggle option to switch between each table, but due to a recent change request the entire report needs to be on one screen.
(=IIF(Parameters!SelectAScreen.Value = "InvoiceDetails",false,true))
I think if you add an extra row above your data (outside the group) and set the RepeatOnNewPage to False, it should work the way you want it too.
Some version of #StevenWhite's comment above is the only way I know to do this. One way to do it is to do a union with a dummy key to force the title row to the top of each table:
select 1 as dummyKey,
'Title text for table1'
union all
select 2 as dummyKey,
<columns> from <table1>
order by dummyKey, <other sort columns>
and repeat for each table's dataset.
If necessary you can also do conditional formatting to make the title row stand out and look like a title.

How to give page break in SSRS

I am making a very simple report in SSRS. I am trying to do the following:
On page 1 display following text
THIS IS PAGE 1
On page 2 display following text
THIS IS PAGE 2
I added "Text" field in my report in which I have set the value field to "THIS IS PAGE 1". But I can't find any option to add page break after it. How do I give page break?
I am not sure what is the purpose of having Page Break for you without any content..
but still i tried by adding a table on a report with one column and hide that and it works
Step 1
Create a DataSet with query (commandtext)
Select 'A' AS GRP
UNION
Select 'B' AS GRP
Step 2
Insert a table & set DataSetName as created in step1
Step 3
Click on Table Group & press F4 to Set Page Break Properties value,
Set BreakLocation to Between & PageName to =Fields!GRP.Value (See screenshot for your Ref)
Step 4
From above Step you will see report break into 2 page as there are 2 records from query step 1.. Now next step is to Display Page Number for the insert PageHeader
Step 5
Insert Page Header with textbox expression value as
="THIS IS PAGE " & CSTR(Globals!PageNumber)
Last but not least, Hide unexpected table columns (TextBox) as you just want to display Page Number or Page Header
Output of the report will be like

SSRS Get table last value from previous page

In Reporting Services imagine that i have a table with 1 column, that when is printed (2 pages) looks like this:
1st Page
Value
1
2
3
2nd Page
Value
4
5
6
What I need is that when it is printed looks like this:
1st Page
Value
1
2
3
2nd Page
Value
Last Value From Page 1: 3
4
5
6
Briefly what i want is that,in each page of the report (except in page 1) the first value is the last value from previous page...
Is that possible?
Thanks in advance...
There is built-in functionality to display row and column headers on multiple pages. This also tells you how to keep a static row or column visible while scrolling. Note the KeepWithGroup and RepeatOnNewPage properties.
If the rows you would like to repeat across pages are not group headers, you may have to make your own page group. This approach is not very pretty, but you could structure the data with flags to signal its own page breaks, and then manually include a repeat row after the page break. So the data set would look like:
Value PageFlag
1 1
2 1
3 1
3 2
4 2
5 2
6 2
You would add a grouping on PageFlag with a page break for each group.
On the Page Breaks tab, select Between each instance of a
group to add a page break between each instance of a group in the
table.
There is more detail on the KeepTogether property here. You can also read up on Pagination and Page Layout.