Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 EMERGENCY

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-03-17 : 13:00:11
Hi group:

I have an emergency. I created a report. In the Percentage Column, the below is the correct calculation. However, I need to have a Zero in front of any reasult less than 1.0%.

For example 0.47% How can I do that? Help!!!!!! :(

=Round((Fields!Net_Receipts.Value-Fields!Deliveries.Value)/Fields!Deliveries.Value*100,2)

Thanks

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-03-17 : 13:31:14
Didn't we already cover this? Have you not learned yet how to apply format strings and how to format fields in reporting services?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandardnumericformatstringsoutputexample.asp

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-03-17 : 13:59:05
Nope we did not cover this one....and the MSDN does not give me a clear answer...:)
Go to Top of Page

jhermiz

3564 Posts

Posted - 2008-03-19 : 10:22:57
quote:
Originally posted by osirisa

Nope we did not cover this one....and the MSDN does not give me a clear answer...:)



You can try something like this:

=IIF(Fields!MyFieldNameHere.Value < 1, "0." & Fields!MyFieldNameHere.Value, Fields!MyFieldNameHere.Value)



Weblog -- [url]http://weblogs.sqlteam.com/jhermiz[/url]
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-03-19 : 11:15:18
This seems like a very mild EMERGENCY.

http://en.wikipedia.org/wiki/False_alarm






CODO ERGO SUM
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-03-19 : 13:04:31
quote:
Originally posted by jhermiz

quote:
Originally posted by osirisa

Nope we did not cover this one....and the MSDN does not give me a clear answer...:)



You can try something like this:

=IIF(Fields!MyFieldNameHere.Value < 1, "0." & Fields!MyFieldNameHere.Value, Fields!MyFieldNameHere.Value)




Wouldn't you just use a format code? Don't embedd formatting considerations into your expressions when you don't need to. Keep it simple.

Set the field to:

=Fields!Net_Receipts.Value-Fields!Deliveries.Value / Fields!Deliveries.Value

And then right-click on the field, choose Properties, and then go to the Format tab, and enter a format code of:

0.00%

That's pretty much it. This will round to 2 decimal places and you don't even need to multiply by 100.

osirisa -- if you are working with reporting services, you should really brush up completely on the basics such as field formatting. There's even a little HELP button right there on the field properties when you right click. Click HELP and it has all the information you need.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -