SSRS: show a value only on the last page
Compare Globals!PageNumber with Globals!TotalPages to show a value or hide a control only on the last page of an SSRS report.
Still valid SSRS, but only in the page header or footer: PageNumber and TotalPages cannot be used in the report body.
- First written
- Re-read
- Versions
- AX 2012 · D365FO
Totals, signatures or closing notes often belong only on the last page of a document. In SSRS you can get there with an expression that compares the current page with the total pages. The original title said “in the body of the report”, but the note itself ends with the real constraint: these globals only work in the page header and footer.
In D365FO today
The expression is standard SSRS. Learn confirms the constraint: “PageNumber can only be used in an expression in a page header or page footer”, and the same holds for TotalPages (Built-in Globals and User references in a paginated report). To show something on the last page, put it in the page footer.
The original note
To display a value only on the last page, use an expression like this on the field:
=iif(Globals!PageNumber=Globals!TotalPages,data, nothing)
To hide a control only on the last page, use an expression like this on the visibility property:
=iif(Globals!PageNumber=Globals!TotalPages,false,true)
Remember that you can use the global properties only in the header and footer sections.
References
- Built-in Globals and User references in a paginated report (Microsoft Learn)