SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Numeric Formatting - Display Zero as Dash?


Numeric Formatting - Display Zero as Dash?

Author
Message
peterzeke
peterzeke
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6238 Visits: 1768
I might be overlooking the obvious, but I can't figure out how to display a zero (0) as a "-" in SSRS 2005 using Format codes. I have a column that contains either a 1 or 0, so rather than display zero, I'd like to display a dash. (I want to avoid using IIF() or Switch() functions)



Example:

Current Output=

ClientTrained?
==========
0
0
0
1
0
1


Desired Output=

ClientTrained?
==========
-
-
-
1
-
1

Thanks,
Pete



Daniel Bowlin
Daniel Bowlin
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21260 Visits: 2629
2008 has a - for a 0 built in. When I choose it the expression it creates is:

0.00;(0.00);'-'


Try putting that in your format.
durai nagarajan
durai nagarajan
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10150 Visits: 2893
looks same like iif

can i know why you want to avoid iif

thanks

Regards
Durai Nagarajan
peterzeke
peterzeke
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6238 Visits: 1768
durai nagarajan (5/12/2011)

looks same like iif

can i know why you want to avoid iif

thanks



I have about a dozen columns in a table where the field values are either 1 or 0. For satisfactory display, it would be best to format the zeros to dashes. If a simple format code exists, then it saves the effort of having to write conditional expressions for each field.



peterzeke
peterzeke
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6238 Visits: 1768
Daniel Bowlin (5/12/2011)
2008 has a - for a 0 built in. When I choose it the expression it creates is:

0.00;(0.00);'-'


Try putting that in your format.


Daniel -- thanks for checking SSRS 2008. That format code works. Ironically, as I was saving the formatting expression in a plain ol' text file within my "SSRS bag of tricks" folder, I discovered I had come up with the formatting code a long time ago -- I just didn't label the file very well.

So, I have your format code along with my original one =
#,###;(#,###);-


Looks like the third segment is what handles zeros.

Thanks again,
Pete



durai nagarajan
durai nagarajan
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10150 Visits: 2893
Is ther any way around for ssrs 2005.

thanks in advance.

Regards
Durai Nagarajan
Daniel Bowlin
Daniel Bowlin
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21260 Visits: 2629
That format should work in 2005 also.
dbanks 93850
dbanks 93850
Valued Member
Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)

Group: General Forum Members
Points: 70 Visits: 17
Ideally you want #,##0.00;(#,##0.00);'-' Add a 0 if you don't want the 0 to drop off.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search