[英]How to format a number with an expression in SSRS based on a value?
I have fields called price
and minIncrement
in my DataSet for my SSRS 2012 report. 我的SSRS 2012报表的数据集中有一个名为
price
和minIncrement
字段。 I want to format the price
using an expression based on the minIncrement
field. 我想使用基于
minIncrement
字段的表达式来格式化price
。 For example if the price
is 94.95000
and the minIncrement
is 0.01
, then I want the price
displayed on the report as 94.95
. 例如,如果
price
为94.95000
, minIncrement
为0.01
,那么我希望报表上显示的price
为94.95
。 If the price
is 12345.000000
and the minIncrement
is 1
, then display the price
as 12345
. 如果
price
为12345.000000
并且minIncrement
为1
,则显示price
为12345
。
Is there a way to do that? 有没有办法做到这一点? Possible
minIncrement
values are 可能的
minIncrement
值为
0.000100
0.010000
0.100000
0.250000
1.000000
You could create an expression, something like: 您可以创建一个表达式,例如:
=Format(
Fields!Price.Value,
Switch(
Fields!MinIncrement.Value = 0.000100, "0.0000",
Fields!MinIncrement.Value = 0.010000, "0.00",
Fields!MinIncrement.Value = 0.100000, "0.0"
)
)
Just expand the Switch
statement with the other possible values for MinIncrement. 只需将
Switch
语句扩展为MinIncrement的其他可能值即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.