SSRS Format to display as percent

亡梦爱人 提交于 2019-12-01 04:46:23

A standard principle is to separate data from display, so use the Value property to store the data in its native data type and use the Format property to display it how you want. So rather than use an expression formatting the Value property such as =Format(Fields.SomeField.Value, "0.00%") leave the Value as =Fields!SomeField.Value and set the Format property to P2.

This is especially important when exporting your report to Excel because if you have the right data type for your data it will export to Excel as the right data type. If you use the Format function it will export as text, making sorting and formula not work properly.

The easiest thing to do to control the formatting is use the standard numeric formats. Click on the cell or range of cells that you want to have a certain format and set the Format property. They are a format specifier letter followed by an optional digit for precision (number of decimal places). Some useful ones are:

C Currency with 2 decimal places (by default)

N4 Number with 4 decimal places

P0 Percentage with no decimal places

Click on the link above for the full list. Format the number cells as numbers and the percents as percents - you don't need to try to make one format string fit every cell.

These standard numeric formats also respect regional settings. You should set your report's Language property to =User!Language to use the user's regional settings rather than the report server's.

If the number is already * 100 eg. 9.5 should be shown as 9.5% then use the format:

0.00\%

9.5 -> 9.5%

0.34 -> 0.34%

This way you can use the standard number formatting and just add the % to the end. The \ escapes the %, preventing the *100 in formatting (which would make 9.5 show 950%.).

=iif(Fields!Metric.Value = "Gross Profit %",
 Format(Fields!LVS_Web.Value,"P"),
 iif(Fields!Metric.Value = "Order Count",
 Format(Fields!LVS_Web.Value,"G4"),
  Format(Fields!LVS_Web.Value,"C")))

This is what saved me and did what I wanted. There is another error, but it's my bosses fault, so now I get to laugh at him. Thanks everyone.

RAP

Source:

https://technet.microsoft.com/en-us/library/bb630415(v=sql.100).aspx

This is simple to use,

Percent of (the sum of line item totals for the current scope)/(the sum of line item totals for the dataset). This value is formatted using FormatPercent specifying one decimal place.

="Percentage contributing to all sales: " & FormatPercent(Sum(Field!LineTotal.Value)/Sum(Field!LineTotal.Value,"Sales"),1)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!