Thursday, May 26, 2011

Formatting RDL/RDLC values as percentage

I thought I'd share how to format percentage values in ReportViewer report.
Say your data source has the following fields:
  • TotalLow
  • TotalHigh
  • Total

Suppose we want to display the values for TotalLow and TotalHigh as  percentage of Total.

We can use the following expressions.
=String.Format("{0:p0}",Sum(Fields!TotalLow.Value)/Sum(Fields!Total.Value))
=String.Format("{0:p0}",Sum(Fields!TotalHigh.Value)/Sum(Fields!Total.Value))

You notice the RDL/C allows you to use .NET String object Format method.

Hope this helps.

No comments: