The report history feature of the Report Manager enables you to keep copies of a report’s past execution. This lets you save the state of your data without having to save copies of the data itself. You can keep documentation of inventory levels, production schedules, or financial records. You can look back in time, using the report history to do trend analysis or to verify past information.
To demonstrate the report history feature of Reporting Services, we need a report whose results change often. It just so happens we have such a report in our Chapter08 solution. The TransportMonitor report provides different values every time the report is run. We can move that report to the Report Server, and then enable the report history.
Open the Report Manager and navigate to the Chapter 08 folder.
Use the Upload File button to upload the TransportMonitor report from the Chapter 08 solution.
Select Show Details, if it is available in the report viewer toolbar. If it is unavailable, you are already in Show Details mode.
Click the icon in the Edit column for the TransportMonitor report. The Properties page appears.
Click Parameters on the left side of the page. The Parameters page appears.
Click the Has Default check box and type 1304 for Default Value.
Click Apply.
Click Data Sources on the left side of the page. The Data Sources page appears.
Click Browse. The Data Source page appears.
Use the tree view to find the 2006 Conference folder in the tree structure. The 2006 Conference folder is inside the Galactic Delivery Services folder.
Select the Galactic shared data source and click OK.
Click Apply.
Click History on the left side of the page. The History Properties page appears, as shown in Figure 11–7.
Figure 11–7: The History Properties page
Make sure the Allow History to Be Created Manually check box is checked. If it is not, check it and click Apply.
Click the View tab at the top of the page. Remember, this report has autorefresh set. After a few seconds, the report refreshes and new data is displayed.
One way to create a report history is to do so manually. We can give this a try in the following example:
Select the History tab. (This is the History tab along the top, not the History link on the left side of the page.) The Create/View History page appears.
Click the New Snapshot button in the report viewer toolbar. An entry for a report history snapshot appears.
Click the New Snapshot button two more times to create two more report history snapshots, as shown in Figure 11–8.
Figure 11–8: The Create/View History page
Click the link in the When Run column to the first report history snapshot you created. This report should appear in a new browser window.
Open the other two report history snapshots and compare all three.
As with the cached report instances, the report history snapshots store the intermediate format of the report. Because of this, you can export this report to any of the rendering formats.
Select one of your browser windows containing a report history snapshot.
Export the snapshot to the Acrobat (PDF) file format and open it in Adobe Acrobat Reader.
Close Acrobat Reader and the browser windows containing your report history snapshots.
To make our TransportMonitor report work with report history snapshots, we had to provide a default value for the transport number parameter. These parameters cannot be changed when each snapshot is created. (They can be changed, however, if the report is run normally through the Report Manager.)
Essentially, we are saving report history snapshots for only one transport. To save report history snapshots for other transports, we need to create linked reports with parameters defaulted to the other transport numbers.
Select the Properties tab.
Click General on the left side of the page.
Click Create Linked Report.
Type Transport 1305 Monitor for Name and The Transport Monitor Report for Transport 1305 for Description.
Click OK. The linked report executes.
Select the Properties tab.
Click Parameters on the left side of the page.
Change Default Value to 1305.
Click Apply.
Click the History tab.
Click New Snapshot.
Click the entry for the new snapshot to view it. You can see this is a snapshot for transport number 1305.
Close the browser window containing your report history snapshot.
We can create as many linked reports as we need to collect report history snapshots for the different possible parameter values. Remember, linked reports all point back to a single report definition. If the TransportMonitor report is ever updated, it only needs to be deployed in one location, and all the linked reports will have the updated report definition.
You can create report history snapshots in two other ways, in addition to the manual method just described. You can instruct the Report Server to create a report history snapshot each time it creates an execution snapshot. With this setting turned on, any time the Report Server creates an execution snapshot—either manually or on a scheduled basis—a copy of that execution snapshot is saved as a report history snapshot.
You can also set up a schedule to create your report history snapshots. Let’s give that a try:
Click the Chapter 08 link at the top of the page.
Click the icon in the Edit column for the TransportMonitor report. (The original report, not the linked copy.) The Properties page appears.
Click History on the left side of the page.
Check the Use the Following Schedule to Add Snapshots to Report History check box.
Report-Specific Schedule is selected by default. Click Configure next to Report-Specific Schedule. The Schedule page appears.
Select Hour.
Change the Hourly Schedule to run every 0 hours 1 minutes. Set Start Time to five minutes from now.
Today’s date should be selected for Begin Running This Schedule On.
Check the Stop This Schedule On check box and set it to tomorrow’s date.
Click OK to return to the History Properties page. Note the description of the schedule you just created under Report-Specific Schedule.
Click Apply to save your changes to the history snapshot settings.
Select the History tab.
As each minute passes beyond the time you chose for the schedule to start, a new report history snapshot is created. You need to refresh your browser to see the new history snapshots in the list.
Not all users can change report history snapshot properties. To change the report history snapshot properties for a report, you must have rights to the Manage Report History task. Of the four predefined security roles, the Content Manager and My Reports roles have rights to this task.
You will not usually have a report that requires a new report history snapshot every minute of the day, as we set up in our example. Even so, report history snapshots can start to pile up if you let them. Making business decisions about the number of history snapshots to save for each report is important. Even more important, then, is to implement those business decisions and manage the number of history snapshots being saved on the Report Server.
Reporting Services provides a way to limit the number of history snapshots saved for any given report. Let’s take a look and put a limit on our TransportMonitor report snapshots at the same time.
Select the Properties tab.
In the Select the Number of Snapshots to Keep section of the page, select the Limit the Copies of Report History option.
Set the limit to 5.
Click Apply to save your changes to the history snapshot settings.
Click OK in response to the warning dialog box.
Select the History tab.
If you waited long enough to accumulate more than five report history snapshots, you see the list was reduced to the five most recent history snapshots. The older history snapshots were automatically deleted. As each new history snapshot is created, the oldest history snapshot is deleted, so the total always remains at five. Again, remember, you need to refresh your browser to see these changes as each minute passes.
We chose to set a limit on the number of history snapshots saved for this report. In addition to this option, you have two others to choose from (see Figure 11–7). You can keep an unlimited number of history snapshots, or you can use the default setting for history snapshot retention. You see how to change this default setting in the section “Configuration Options and Default Values.”
In addition to using the history snapshot limit on the History Properties page, you can also manually delete unwanted history snapshots.
Refresh your browser.
Caution | If you reached the limit of five history snapshots, the Report Server is automatically deleting old history snapshots as new ones are created. If your Create/View History page is not current, you could try to delete a history snapshot that has already been removed by the Report Server. This results in an error. |
Check the check box in the Delete column for three of the snapshot history entries.
Click Delete in the History tab toolbar.
Click OK to confirm the deletion.
The Report Server again accumulates history snapshots for this report until it has reached our five snapshot limit. At that point, it again deletes the oldest history snapshot as each new one is created.
We can now disable the creation of report history snapshots for this report, so we are not wasting valuable execution cycles.
Select the Properties tab.
Uncheck the Use the Following Schedule to Add Snapshots to Report History check box.
Click Apply.
Select the History tab.
New history snapshots are no longer created for this report on a scheduled basis. Note, however, that the existing history snapshots were not deleted. These history snapshots are still available for viewing, even though the schedule that created them was disabled.
One of the best features of report history snapshots is this: they are not lost if the definition of the underlying report is changed. Let’s see this in action.
Start Visual Studio or the Business Intelligence Development Studio and open the Chapter 08 solution.
Open the TransportMonitor report layout.
Select the Data tab. Select the TransportMonitor dataset.
Click the ellipsis button (…) to view the Dataset dialog box.
Select the Filters tab.
Select =Fields!Item.Value from the Expression column drop-down list. Select != from the Operator column drop-down list. Enter Thruster in the Value column. This filter removes the thruster data from the report.
Click OK to exit the Dataset dialog box.
Select the Preview tab. Check 1304 in the Transports drop-down list and click View Report. Note the Thruster graph is missing.
Click Save All in the toolbar.
Right-click the TransportMonitor report in the Solution Explorer and select Deploy from the Context menu.
After the deployment has succeeded, close Visual Studio or the Business Intelligence Development Studio.
Return to the Report Manager in your browser.
Select the View tab for the TransportMonitor report. Note, the report now includes our change, eliminating the thruster data from the report.
Select the History tab. We still have some report history snapshots based on the old report definition.
Click New Snapshot to manually create a report history snapshot based on the new report definition. Our five history-snapshot limit is still in effect, so one of the old history snapshots may have to be deleted to make room for the new one.
Click the most recent history snapshot to view it. It does not contain thruster data because it is based on the new report definition.
Close this browser window.
Click the oldest history snapshot to view it. It does contain thruster data because it is based on the old report definition.
Close this browser window.
Just like the cached report instance, the report history snapshot contains both the report definition and the dataset. Therefore, it is unaffected by subsequent changes to the report definition.