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.

Global References in SSRS 0

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.

Format Table Report in SSRS 1

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

-- SSRS Build-in Fields Example
SELECT Prodcat.EnglishProductCategoryName,
       prodSubcat.EnglishProductSubcategoryName,  
       prod.EnglishProductName, 
       prod.Color, 
       fact.[TotalProductCost],
       fact.SalesAmount, 
       fact.TaxAmt,
       fact.[OrderDate],
       fact.[ShipDate] 
FROM dbo.DimProduct as prod 
  INNER JOIN 
dbo.DimProductSubcategory AS prodSubcat ON 
       prod.ProductSubcategoryKey = prodSubcat.ProductSubcategoryKey 
  INNER JOIN  
dbo.DimProductCategory AS Prodcat ON 
       prodSubcat.ProductCategoryKey = Prodcat.ProductCategoryKey 
  INNER JOIN  
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 SSRS Table ReportFormat-Table Report in SSRS article to understand the steps involved in creating and formatting Table Report, and see Grouping in SSRS Table Report article for Grouping techniques.

Global References in SSRS 1

Let me show you the report preview

Global References in SSRS 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.

Global References in SSRS 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.

Global References in SSRS 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.

Global References in SSRS 5

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

Global References in SSRS 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 to Report article to understand the formatting options

Global References in SSRS 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

Global References in SSRS 8

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

Global References in SSRS 9

You can see them in the report preview.

Global References in SSRS 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.

Global References in SSRS 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
Global References in SSRS 12

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

Global References in SSRS 13

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

Global References in SSRS 14

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

Global References in SSRS 15