# Show blank for zero values

**URL:** <https://forum.servoy.com/t/show-blank-for-zero-values/3210>\
**Category:** Classic Servoy\
**Created:** [December 5, 2004, 1:14pm UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210 "2004-12-05T13:14:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![faheemhameed](https://avatars.discourse-cdn.com/v4/letter/f/7ea924/32.png) [@faheemhameed](https://forum.servoy.com/u/faheemhameed)\
**Post date:** [December 5, 2004, 1:14pm UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210/1 "2004-12-05T13:14:22Z")

</div>

How can I format a numeric field to show blanks if it contains a zero?

Thanks

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [December 6, 2004, 10:40am UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210/2 "2004-12-06T10:40:46Z")

</div>

use # - (zero shows as absent)

---

<div class="post-metadata">

**Author:** ![faheemhameed](https://avatars.discourse-cdn.com/v4/letter/f/7ea924/32.png) [@faheemhameed](https://forum.servoy.com/u/faheemhameed)\
**Post date:** [December 6, 2004, 11:48am UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210/3 "2004-12-06T11:48:01Z")

</div>

Thanks! I would try that.

---

<div class="post-metadata">

**Author:** ![faheemhameed](https://avatars.discourse-cdn.com/v4/letter/f/7ea924/32.png) [@faheemhameed](https://forum.servoy.com/u/faheemhameed)\
**Post date:** [April 1, 2005, 5:18pm UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210/4 "2005-04-01T17:18:51Z")

</div>

Hi Jan,

This does not work completely.

I have a value 0 in a number field. I just # as format. But it shows the 0 instead of blank

Thanks  
Hameed

---

<div class="post-metadata">

**Author:** ![faheemhameed](https://avatars.discourse-cdn.com/v4/letter/f/7ea924/32.png) [@faheemhameed](https://forum.servoy.com/u/faheemhameed)\
**Post date:** [April 1, 2005, 5:25pm UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210/5 "2005-04-01T17:25:20Z")

</div>

Also when I clear the number field, it puts a zero by default. But I have not set any default value. How to overcome that please.

Thanks

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [April 22, 2005, 12:48pm UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210/6 "2005-04-22T12:48:46Z")

</div>

It seems a bug from SUN, in the docs they say # - show 0 as absent  
[http://java.sun.com/j2se/1.4.2/docs/api … ormat.html](http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html)  
but it does not show, we will report this to SUN.

BTW it seems sort of working (zero not shown) when “#.00” is used as format

---

<div class="post-metadata">

**Author:** ![sebster](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@sebster](https://forum.servoy.com/u/sebster)\
**Post date:** [May 30, 2005, 9:58am UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210/7 "2005-05-30T09:58:16Z")

</div>

Actually the docs are probably a bit lousy, but this is really expected behavior. The # means blank _padding_, that is, “###” with the number 3 for example is shown as " 3". However, it will always output a number (and never a total blank), so “###” with the number 0 becomes " 0".

The comment from the SUN source code is clearer than the JavaDoc:

// Handle patterns with no ‘0’ pattern character. These patterns  
// are legal, but must be interpreted. “##.###” → “#0.###”.  
// “.###” → “.0##”.

/\* We allow patterns of the form “####” to produce a zeroDigitCount of

- zero (got that?); although this seems like it might make it possible
- for format() to produce empty strings, format() checks for this
- condition and outputs a zero digit in this situation.

Thus this behavior is intentional.

I’m afraid you’re going to have to find a different way of displaying an empty string for the number zero… (maybe using a calculation).

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [January 24, 2012, 11:18am UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210/8 "2012-01-24T11:18:35Z")

</div>

Last post on this subject was 2005.

Now it is 2012 and Servoy 5.2 / 6.0

Is there already a solution for this situation?

I have a column in the database numeric(9, 4)

Default format is #,##0.00##

So it shows:

DB Value Format  
5,0000 5,00  
5,2500 5,25  
5,2570 5,257

But in case of value 0, I would like to see an empty field (so blank when zero).  
Otherwise I must allow NULL values in the database and let 0 be a NULL value, but that is not really what I prefer.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [January 24, 2012, 11:25am UTC](https://forum.servoy.com/t/show-blank-for-zero-values/3210/9 "2012-01-24T11:25:45Z")

</div>

this is just how the formatting works  
and if you have a 0 then you have a 0, that is really not the same a null (which is nothing)

if you want something else, what you can do is place a converter in between, so that 0 are converted to null and visa versa i guess
