Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssrs leading zeroes and only show decimals when necessary

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.

like image 812
iDesi Avatar asked Nov 15 '13 20:11

iDesi


People also ask

How do you avoid round off in SSRS?

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.

How do you get to 2 decimal places in SSRS?

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!


1 Answers

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")

Format Number Example

like image 110
Sam Avatar answered Sep 28 '22 07:09

Sam