Jeff Townes' Blog
My Links
Blog Stats
  • Posts - 9
  • Stories - 0
  • Comments - 8
  • Trackbacks - 3
Archives

I have been working recently with SQL Server 2005 Reporting Services to display dollar sums and volume sums, and I’m happy to report [I couldn’t resist] that I’ve found a neat trick for formatting non-currency negative numbers. 

Our client requested that we apply the following formatting rules to report figures:

·         Use parenthesis instead of a minus sign to display negative values

·         Display no decimals and format numbers with a comma when they exceed 999

·         Display the currency sign for financial figures

These are seemingly simple requirements to accomplish with standard .NET format strings.  First, setting the Format property of the SSRS textbox (or other control) to C0 [c-zero] will format numbers as currency with no decimal places.  This format will also automatically add parenthesis around negative numbers:

o   $999 or $1,000 for positive dollar figures

o   ($900) or ($1,000) for negative dollar figures

Unfortunately, none of the easy-bake format strings for numeric values appeared to automatically display parenthesis for negative numbers.  I tried N0 [n-zero], G0 [g-zero], D0 [d-zero] and various other combinations.  The answer was to use a custom format string instead.

In order to format numeric, non-currency values to use parenthesis when displaying negative numbers, set the Format property of the SSRS textbox to “#,0;(#,0)” (and omit the quotation marks).  Problem solved!

Finally, if you’re looking to add a bit extra, format negative numbers to display in red font instead of black by adding this expression to the Color property of the textbox: 

=IIf([Expression to Evaluate] >= 0, "Black", "Red")

Or, in my case, the specific formula was:

=IIf(SUM(Fields!AmountBilled.Value) >= 0, "Black", "Red")

Happy Reporting!
posted on Wednesday, December 12, 2007 9:21 PM
Feedback
  • # Forex Back Testing Software
    Forex Back Testing Software
    Posted @ 9/23/2008 12:02 AM
    Execs & Accounts UK and EU: GroupM, Phorm, Brightcove- GroupM makes Allan CEO of MediaCom; Coke man moves to Phorm; Brightcove scores video deal with Number 10. Aug 25, 2008 RNM’ s U. K. Closing Signals Slow Mobile Video Uptake- The mobile video ad…
  • # click here
    click here
    Posted @ 9/27/2008 10:19 AM
    Forex Trading Course is designed to help learn the forex market completely. Feel the power of a successful trader with our sophisticated online Forex trading system. Download the best sofware over here and learn all the Forex trade secrets.
  • # forex trading online
    forex trading online
    Posted @ 9/27/2008 12:44 PM
    « Roche Agrees to Buy ARIUS Research for C 191 Million (Update1)- Bloomberg UPDATE 1- Baird upgrades SunTrust to outperform- Reuters» 23 07 2008 FOREX- Dollar bolstered by oil, stocks; yen suffers- Reuters Posted by:
Title  
Name  
Url
Comments   
Protected by Clearscreen.SharpHIPIn order to prevent spam, please enter the code to post a comment.:
Jeff Townes