简体   繁体   English

如何使用基于值的SSRS中的表达式格式化数字?

[英]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报表的数据集中有一个名为priceminIncrement字段。 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 . 例如,如果price94.95000minIncrement0.01 ,那么我希望报表上显示的price94.95 If the price is 12345.000000 and the minIncrement is 1 , then display the price as 12345 . 如果price12345.000000并且minIncrement1 ,则显示price12345

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM