Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
nitishb24
Regular Visitor

How to Retrieve Total Page number from the Sub Report

Hi Team ,

There is a requirement where we need to show the total page number of the sub report in the parent report for paginated reports using  Power BI report builder .

 

Could you please suggest any good solution for implementing the same ?

 

Thanks & Regards,

Nitish

1 ACCEPTED SOLUTION
aduguid
Super User
Super User

Go to Report > Report Properties > Code

 

 

Public Shared SubReportPageCount As Integer

Public Function GetSubReportPageCount() As Integer
    Return SubReportPageCount
End Function

Public Sub SetSubReportPageCount(ByVal pageCount As Integer)
    SubReportPageCount = pageCount
End Sub

 

 

In your subreport, create a text box and set its value to the following expression

 

 

=Code.SetSubReportPageCount(Globals!OverallTotalPages)

 

 

In the parent report, create a text box and set its value to the following expression

 

 

=Code.GetSubReportPageCount()

 

 

 

or you could use a parameter, "SubReportTotalPages" in the subreport with a value of =Globals!OverallTotalPages and pass the parameter to the parent report by adding the same named parameter to the parent report and set the value to the subreport's parameter. 

In the parent report you could then just reference the parameter

 

=Parameters!SubReportTotalPages.Value

 

 

View solution in original post

2 REPLIES 2
nitishb24
Regular Visitor

Thank you @aduguid  for your suggestions 🙂 !!!!

We will try this above approach and check where  it is working or not !!! Thanks for your support.

aduguid
Super User
Super User

Go to Report > Report Properties > Code

 

 

Public Shared SubReportPageCount As Integer

Public Function GetSubReportPageCount() As Integer
    Return SubReportPageCount
End Function

Public Sub SetSubReportPageCount(ByVal pageCount As Integer)
    SubReportPageCount = pageCount
End Sub

 

 

In your subreport, create a text box and set its value to the following expression

 

 

=Code.SetSubReportPageCount(Globals!OverallTotalPages)

 

 

In the parent report, create a text box and set its value to the following expression

 

 

=Code.GetSubReportPageCount()

 

 

 

or you could use a parameter, "SubReportTotalPages" in the subreport with a value of =Globals!OverallTotalPages and pass the parameter to the parent report by adding the same named parameter to the parent report and set the value to the subreport's parameter. 

In the parent report you could then just reference the parameter

 

=Parameters!SubReportTotalPages.Value

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.