How to format a number with an expression in SSRS based on a value?
I have fields called price
а также minIncrement
in my DataSet for my SSRS 2012 report. I want to format the price
using an expression based on the minIncrement
поле. Например, если price
является 94.95000
и minIncrement
является 0.01
, then I want the price
displayed on the report as 94.95
, Если price
является 12345.000000
и minIncrement
является 1
, then display the price
как 12345
,
Есть способ сделать это? Возможный minIncrement
значения
0.000100
0.010000
0.100000
0.250000
1.000000
1 ответ
Решение
Вы можете создать выражение, что-то вроде:
=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"
)
)
Просто расширить Switch
заявление с другими возможными значениями для MinIncrement.