I am working on a SSRS report which needs to show leading zeroes if the item has decimals and is less than one, but only show decimals if needed. I'll try to break this down via examples.
35.00 should be displayed as 35
35.5 should be displayed as 35.50
.01 should be displayed as 0.01
01 should be displayed as 1
I have the decimal portion of this working by using Format(value, "##.##") but I am struggling a bit with the leading zeroes portion of things.
Try using "Floor". It effective rounds down to the nearest integer. You'll find this under the Math functions. Note, there's also a Floor function in Transact-SQL that works the same way in case you need to do some of the processing in your SQL script.
Going to the Properties Window (F4) and find Number, then enter N2 as the format (or N0 is you want no decimal places) will generate a number in Excel. Just worked for me when I used cDbl as here: FormatNumber(Sum(cDbl(Fields!
It's not something that can be achieved by using format strings on there own. However... If you convert your value to double using the CDbl
function and output that, then set your format string on the text-box to custom, and use
=iif(CDbl(Fields!val.Value)=Floor(CDbl(Fields!val.Value)),"0","0.00")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With