Global References in SSRS

The Built-in Fields Collection includes the Global references in SSRS. And the references include the global variable, which is pre-defined by Microsoft. These are the standard SSRS Global References variables used in every report that we design, such as Page Numbers, Total Page Numbers, etc.

List of Global References in SSRS

The following are the list of available Global References in SSRS.

List of Available Global Variables

and their description is as follows

MemberData TypeDescription
ExecutionTimeDateTimeIt will display the date and time of report execution.
PageNumberIntegerIt will return the current page number. It will assign 1 to the first page, and then it will increment by 1. If there are any page breaks, then this will return the result as per the page breaks. You can control the numbers by RestPageNumber property in Page Break.You have used this in either Page header, or Footer.
ReportFolderStringThis will return the folder path that contains the report.
ReportNameStringThis will return the report name that you assigned while creating the report.
ReportServerURLStringThis will return the report Server URL on which the current report run.
TotalPagesIntegerIt returns the total number of pages returned by the report.

If the report doesn’t have the page breaks then this will return the same result as OverAllTotalpages

PageNameStringIt returns the name of the page.

Use this in either SSRS Page header, or Footer.

OverAllPageNumberIntegerReturns the Current Page Number. This value is not affected by the ResetPageNumber property in Page Breaks. You can use this in either Page header, or Footer.
OverAllTotalpagesIntegerReturns the Total Number of Pages. This value is not affected by the ResetPageNumber property in Page Breaks.This is used in either Page Header or Footer
RenderFormatRenderFormatIt returns the name of the renderer that we configured in the Reporting Service configuration file.

Global References in SSRS Example

For this example, We are going to use the below-shown DataSet. Please refer to Shared Data Source and Dataset articles to understand the steps involved in creating Shared Data sources and Dataset that we used for this report.

Table DataSet 1

And the Custom SQL query that we used in the above Dataset is:

-- Build-in Fields Example
SELECT Prodcat.EnglishProductCategoryName,
FROM dbo.DimProduct as prod 
dbo.DimProductSubcategory AS prodSubcat ON 
       prod.ProductSubcategoryKey = prodSubcat.ProductSubcategoryKey 
dbo.DimProductCategory AS Prodcat ON 
       prodSubcat.ProductCategoryKey = Prodcat.ProductCategoryKey 
dbo.FactInternetSales AS fact ON 
       fact.ProductKey = prod.ProductKey
WHERE SalesAmount >= 3500

To explain the usage of the Global resources in SSRS Reports, We are going to use the below-shown report.

Please refer Table ReportFormat Table article to understand the steps involved in creating and formatting Table Report, and see Grouping in Table article for Grouping techniques.

Simple Table Report

Let me show you the report preview

Table Preview 2

To add the SSRS Global variable, you have to drag and drop the required variable on to the Page Header or Footer.

For now, we are adding the ReportName variable to the header. I suggest you refer to Add Page Headers and footers article to understand the steps involved in adding header & Footer.

Add Report Name Global References Variable 3

Click on the Preview tab to see the report preview. From the below screenshot, you can see that the SSRS global variable is showing the report name.

View ReportName global variable 4

Let me format the Global variable. If you observe the Item, it is a text box. So please right-click on the variable and select the Text Box Properties option.

Format Global References Variable 5

Once you select the Text Box Properties.. option, a new window called Text Box Properties will be opened.

Add Global References Variable 6

Under the Font tab Please change the text box font. First, we will change the font family Property to Cambria, Size to 14pt, Font Style property to Bold, and color to dark Green. I suggest you refer Add TextBox article to understand the formatting options

Change font of a Add Global References Variable 7

Click the OK button to close the properties window. Let me show you the Report Preview. Now you can see the Formatted Global Variable i.e., Report Name

Add Global References Variable 8

Let me add two more variables to the existing report, and this time add them to Page Footer.

Add ReportName Global References Variable in SSRS 9

You can see them in the report preview.

View ReportName Global References Variable 10

If you require to combine one or two global variables or to create a complex variable using the Global variable, then you can use the Expression to built one.

Here we added one Empty TextBox to the page footer, and right-click on it will open the context. Please select the Expression option.

Expression 11

Once you select the Expression.. option, a new window called the Expression will open.

Use this expression window to combine one or more global variables. Here we will display Page Number along with the Total pages in one text box.

=Globals.PageNumber & " of " & Globals.TotalPages
Combine multiple Global References Variables 12

Once you complete with the expression, Please click the OK button to close the expression window. Let me show you the report preview

Preview Global References Variable 13

The report is large so let me scroll down to the end of the first page

Add Global References Variable 14

Let me navigate to the Last page. As you can see that the page number is updated.

Add Global References Variable 15