Add Page Numbers to SSRS Report

This SSRS article shows how to add page numbers to a report using the global variables. To do this, we must use the Page Numbers to combine PageNumber and TotalPages variables.

Right-Click on the Datasets folder to create a new DataSet. The screenshot below shows the data set we will use for this example.


The Sql query that we used above SSRS example is:

SELECT SubCat.[EnglishProductSubcategoryName] AS SubCategory, 
       Prod.EnglishProductName AS ProductName, 
       SUM(Fact.OrderQuantity) AS Orders, 
       SUM(Fact.TotalProductCost) AS ProductCost, 
       SUM(Fact.SalesAmount) AS Sales, 
       SUM(Fact.TaxAmt) AS Tax
FROM FactInternetSales AS Fact
INNER JOIN DimProduct AS Prod ON Fact.ProductKey = Prod.ProductKey
INNER JOIN DimProductSubcategory AS SubCat ON Prod.ProductSubcategoryKey = SubCat.ProductSubcategoryKey 
GROUP BY SubCat.[EnglishProductSubcategoryName],Prod.EnglishProductName, Prod.Color

How to add Page Numbers to SSRS Report?

We designed a simple table report and formatted the font and colors to demonstrate the process of adding page numbers.

Simple table

The below image shows the report preview.

Report Preview

Since the numbers have to repeat on each page, we have to place them in the page footer or header. So, right-click on the empty space, choose the insert option, and select Page Footer.

Add Page Footer

Right-click within the page footer, choose insert, and then select the text box option to add a text box field.

Insert a Text Box

Right-click on the text box and select the expression option from the context menu.

Write an Expression

Write the following expression to add or display page numbers in the SSRS table report.

="Page Number = " + CStr(Globals!PageNumber)
Expression to add Page Numbers to SSRS Table Report

Now you can see the page numbers on each page of the report.

How to add Page Numbers to SSRS Table Report

However, we need to find out how many pages are left. To get this, we have to alter the above expression so that it will display the total pages along with the page number.

="Page Number = " + CStr(Globals!PageNumber) + " Of " + Globals!TotalPages
add Page Numbers and Total Pages to SSRS Table Report

Looking at the preview now, you can see the page number and the total number of pages the report has generated.

add Page Numbers to SSRS Table Report 10

Let me show you the last page.

add Page Numbers to SSRS Table Report