Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
547 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Reporting Services - report and group variables Part two of a three-part series of blogs |
---|
If you're not sure when - or whether - you should be using report or group variables in SSRS, read this blog to find out how to speed up your reports and solve other problems.
|
In this blog
You can download the example report used for this page, which looks like this:
What follows after the title doesn't matter, but we want to ensure that the title gives the same date and time on every single page.
To get a report title as above, you could use the following expression:
="Report printed at " & format(now,"HH:mm:ss")
However, this would give a different title on each page, because (as previously stated) SSRS recalculates all of the textbox expressions on a page whenever you view it. To get round this we need to find some way to freeze the title.
To get round the problem above, we'll create a report variable to hold the title. Since this will be calculated once and once only (when the report first loads), we'll get the same time on every page. First go to the report's properties:
Either right-click on the report edge � | � or use the top menu |
Next, choose to add a variable:
Click on the Variables category, then choose to add one.
Give your new variable a name, then click to create an expression for it:
Here we've called the variable repTitle.
It's a good idea to prefix all report variable names with rep, so as not to confuse them with group variables (all variable names must be unique).
Finally, type in an expression in the usual way:
Create the expression you want in the usual SSRS manner.
Once you've created a report variable, you can include its value in any expression. For our example, first choose to create an expression for a textbox in the report header:
Right-click on the textbox and choose to create an expression.
To put in a reference to a report variable, just choose the Variables category and double-click on (here) the repTitle variable:
Double-click on the repTitle variable to create the expression shown here.
When you preview this report, SSRS will calculate the report title variable repTitle once only, and display this on the top of every page.
We run a two-day advanced SSRS course covering variables (and much more besides), as well as a three-day fast-track SSRS course. We will consider running these as online training if you have a group of people from the same company. You can see all of our SSRS courses here.
Parts of this blog |
---|
|
Some other pages relevant to the above blogs include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.