SSRS - Display current grouping field values in report page header - reporting-services

I'm using SQL Server Data Tools 2012 (Visual Studio 2010) and have a multi-tab report that does a page break on each combination of SalesTerritory and ProductType.
I can label the worksheet tabs of the resulting downloaded Excel spreadsheet by adding a group-level PageName property expression in the Properties window that concatenates the two current grouping criteria values:
=Lookup(Fields!SalesRegionID.Value, Fields!SalesRegionID.Value,
Fields!SalesRegionCode.Value, "SalesRegion") + " " +
Lookup(Fields!ProductTypeID.Value, Fields!ProductTypeID.Value,
Fields!ProductTypeName.Value, "ProductType")
What I'd like to do now is add the same string to the page header of each report page. I can't simply add the above expression in a text box since "field references outside of a data region must be contained within aggregate functions which specify a dataset scope."
So, how do I scope the references in order to display the same string on both current tab
and the page header of each worksheet?

It turns out that the PageName property that I assigned at the group level is also available as a global field. If you add a text box to the page header and open its expression dialog, you will find a field in the Built-in Fields category called "PageName". Double-clicking this will add the following expression:
"=Globals!PageName"
That does it!

Related

Setting ShowParameterPrompts property when returning from a drill through report

In SSRS 2012, I have a Main Report that takes 1 parameter, a dropdown. I have a drill through report that is displayed from a Main Report. When the user is viewing the drill through report, I added a link on the drill through report that goes back to the main report. I use the same parameter value so that the main report is displayed before the drill through report was selected.
The main report displays correctly, but the paremeter area is hidden when the user comes back from the drill through.
I read that there is a ShowParameterPrompts property but I cannot find where to set it.
Is there anyway to set this property from the subreport so the parameter area is showing?
UPDATE
In the Action tab, make sure you select the Go to report option. If you specify the report this way rather than a URL, SSRS will use the appropriate report viewer controls.
You should see something like ...RSViewerPage.aspx?rv:RelativeReportUrl=... in your URL after you click on a drill-through.
The settigs should look like this:
EDIT:
Since this isn't working, let's try the URL method instead. Try this in a browser first to get the URL right and then specify it in the reports. To add the parameter in the URL after ".rdl" add "&rp%3a", then the name of the parameter, "=", and the value. So in your case:
= Globals!ReportFolder & "/SurveyResults.rdl&rp%3aSurveyName=" & <expr>
Of course the expression at the end there would be the value for the parameter. If your survey names have spaces, you'll need to URL encode them by replacing the spaces with "+" or "%20".

Use expression in access report textbox

I have a MS access report that I want to run using a linked excel table (so i cannot make any changes to the table in access).
The report has a text box which takes each row in the table and displays it in the text box and later prints it. I want to add a "*" at the beginning and end of the string and then display it in the text box.
I have done this so far:
- Choose data source (excel linked table) from report view
- In design view, press alt+F8 and drag and drop the column header I want into the report.
When I run the report it shows the report on each page, one page for every row of data which I will print later.
Now in design view after clicking on the text box, I go to property sheet and then the "Data" tab, if I try to change the expression to:
="" & [tablename].[headername] & ""
EDIT: There is an "asterisk" sign between the " " above, i don't know why they don't show.
When I run the report it asks me the parameter for the row number I want and displays the report only for that row. How can I use an expression and still be able to get all rows in the report in different pages?
Thanks!
I did what I didn't want to in order to get the problem solved. I used a query to add an additional column (using an expression) and used the query as my data source. Doesn't look like there is a good way to use the report to directly make changes to the table data and show it in a textbox.

Naming sheets in SSRS when imported to Excel

I have put page breaks in my SSRS report. When report imported to Excel, report is divided into different sheets according to page breaks. Is it possible somehow name those sheets? Thanks for assistance.
You can easily change the tab name by setting the "Page Name" field on the properties sheet of the group (in this example "Buyer") that is providing the page break.
You can't do that with standard SSRS, but I know you can do it with OfficeWriter by SoftArtisans.
It's a proprietary application which isn't cheap, but it let's you create a template in Excel which you can then export the report into. You can do stuff like create charts and pivot tables as well which get populated automatically.
We have used their product and it works well. Their app can also be used to generate other Office artifacts such as Word docs.
(BTW I have no affiliation with SoftArtisans)
But how can I Name each tab with different names?
As Randy pointed out, the PageName is used to name tabs when a report is exported to Excel. Normally you would use a field name for the PageName expression.
If your page breaks are due to a Group, you would probably want to use the name of the group as the PageName. For instance, if you had a report of sales by customer with a separate tab for each customer, you would probably want to use the customer name field as the PageName expression.
=Fields!Customer_Name.Value
If you add the left(buyer,5) etc..into your dataset, put this as the initial group in your report then (page break between each instance of a group) and also use this field as the page name..should do the trick
Navigate to the tablix properties. Type the "SheetName" you need under "PageName" expression. It is better to assign this property from a Global variable, but if you need a custom set name for each of your Excel tabs, this is the way.

SSRS Report - Use column for page breaks, but make invisible

I'm using SQL Server Data Tools 2012 in Visual Studio. I have a Reporting Services report containing a table with some columns that are optional, based on selections from a multivalued parameter, and other columns that are required.
Among the required columns, the first two - call them SalesOutlet and ProductType - are to be used to create separate worksheets when downloaded to an Excel spreadsheet. For instance, I want a worksheet for each of these combinations:
"Springfield" + "Books"
"Springfield" + "Music"
"Portland" + "Books"
... etc. Since these columns are used to create the separate worksheets, it would be redundant to show them in the sheets, so I want to hide them.
I can create the separate worksheets by making SalesOutlet and ProductType be row groups and selecting page breaks "Between each instance of a group" in the Page Breaks tab of the Group Properties dialog. However, if I then go to the Visibility tab and select to Hide the groups, it hides all the columns in my report, since Hide will hide all columns of a group.
How do I use columns for grouping and page break criteria, and hide them in my downloaded result, while still showing their child member columns?
Say you have some data like this:
And a simple report to display the data:
Note that the only column being displayed is Title. However, we are grouping on the other two to create the required group and page breaks:
Don't forget to set up the group-level PageName property to something like:
=Fields!SalesOutlet.Value + " " + Fields!ProductType.Value
To get named worksheets:
This gives the required results of grouping/paging on columns that aren't actually displayed in the report:
It turns out that you can delete the group columns after you've specified them to be used for grouping and page break. You simply right-click on the the handle of the column(s) to be removed and select "Delete Columns" -> "Delete columns only".

How to get named excel sheets while exporting from SSRS

Whenever a single page report is exported to excel, sheet in excel is named by the report name.
If a report has multiple pages, the sheets are named as sheet1, sheet2,....
Is there any way to specify sheet names in SSRS 2005 ?
solution:
Found this after some googleing:
Changing the Sheet names in SQL Server RS Excel: QnD XSLT
Will try out and post an update if it works.
Necromancing, just in case all the links go dark:
Add a group to your report
Also, be advised to set the sort order of the group expression here, so the tabs will be alphabetically sorted (or however you want it sorted).
'Zeilengruppe' means 'Target group'
'Gruppeneigenschaften' means 'Group properties'
Set the page break in the group properties
'Seitenumbruche' means 'Page break'
'Zwischen den einzelnen Instanzen einer Gruppe' means 'Between the individual instances of a group'
Now you need to set the PageName of the Tablix Member (group), NOT the PageName of the Tablix itselfs.
If you got the right object, if will say "Tablix Member" (Tablix-Element in German) in the title box of the properties grid. If it's the wrong object, it will say only "table/tablix" (without member) in the property grid's title box.
Note: If you get the tablix instead of the tablix member, it will put the same tab name in every tab, followed by a (tabNum)! If that happens, you now know what the problem is.
To export to different sheets and use custom names, as of SQL Server 2008 R2 this can be done using a combination of grouping, page breaks and the PageName property of the group.
Alternatively, if it's just the single sheet that you'd like to give a specific name, try the InitialPageName property on the report.
For a more detailed explanation, have a look here: http://blog.hoegaerden.be/2011/03/23/where-the-sheets-have-a-name-ssrs-excel-export/
In SSRS 2008 R2 use PageName property of page group:
http://bidn.com/blogs/bretupdegraff/bidn-blog/234/new-features-of-ssrs-2008-r2-part-1-naming-excel-sheets-when-exporting-reports
To add tab names while exporting to excel, I used the following method:
On the report design window, select the tablix object.
Open properties window of the tablix object.
Add the required tab name to the PageName property.
Run the report
Export the report to Excel.
Now the worksheet name is the same as the PageName property of the tablix object.
Put the tab name on the page header or group TableRow1 in your report so that it will appear in the "A1" position on each Excel sheet. Then run this macro in your Excel workbook.
Sub SelectSheet()
For i = 1 To ThisWorkbook.Sheets.Count
mysheet = "Sheet" & i
On Error GoTo 10
Sheets(mysheet).Select
Set Target = Range("A1")
If Target = "" Then Exit Sub
On Error GoTo Badname
ActiveSheet.Name = Left(Target, 31)
GoTo 10
Badname:
MsgBox "Please revise the entry in A1." & Chr(13) _
& "It appears to contain one or more " & Chr(13) _
& "illegal characters." & Chr(13)
Range("A1").Activate
10
Next i
End Sub
There is no direct way. You either export XML and then right an XSLT to format it properly (this is the hard way). An easier way is to write multiple reports with no explicit page breaks so each exports into one sheet only in excel and then write a script that would merge for you. Either way it requires a postprocessing step.
I was able to get this done following more complex instructions suggested by Valentino Vranken and rao , but here is a more simple approach , for a more simple report . This will put each table on a separate sheet and name them in Excel . It doesn't seem to have an effect on other exports like PDF and Word .
First in the Tablix Properties of of your tables under General , check either Add a page break before or after , this separates the report into sheets .
Then in each table , click the table , then in the Grouping view , on the Row Groups side , select the parent group or the default row group and then in the Properties view under Group -> PageBreak set BreakLocation to None and PageName to the sheet's name .
The Rectangle method
The simplest and most reliable way I've found of achieving worksheets/page-breaks is with use of the rectangle tool.
Group your page within rectangles or a single rectangle that fills the page in a sub-report, as follows:
The quickest way I've found of placing the rectangle is to draw it around the objects you wish to place in the rectangle.
Right click and in the layout menu, send the rectangle to back.
Select all your objects and drag them slightly, but be sure they land in the same place they were. They will all now be in the rectangle.
In the rectangle properties you can set the page-break to occur at the start or end of the rectangle and name of the page can be based on an expression.
The worksheets will be named the same as the name of the page.
Duplicate names will have a number in brackets suffix.
Note: Ensure that the names are valid worksheet names.
You could use -sed- and -grep- to replace or write to the xml header of each file specifying your desired sheet name, e.g., sheetname1, between any occurrence of the tags:
<Sheetnames>?sheetname1?</Sheetnames>
While this usage of the PageName property on an object does in fact allow you to customize the exported sheet names in Excel, be warned that it can also update your report's namespace definitions, which could affect the ability to redeploy the report to your server.
I had a report that I applied this to within BIDS and it updated my namespace from 2008 to 2010. When I tried to publish the report to a 2008R2 report server, I got an error that the namespace was not valid and had to revert everything back. I am sure that my circumstance may be unique and perhaps this won't always happen, but I thought it worthy to post about. Once I found the problem, this page helped to revert the namespace back (There are tags that must also be removed in addition to resetting the namespace):
http://beatheadagainstwall.blogspot.com/2011/03/invalid-target-namespace-when-deploying.html?showComment=1440647962263#c5741523651495876761