INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Does zero still equal null?  (Read 612 times)

wburkett

  • World Citizen
  • ***
  • Posts: 109
Does zero still equal null?
« on: January 02, 2022, 08:19:58 pm »

For a while now I've been annoyed that I can't put the number 0 (zero) into an integer field - it just disappears.  While researching the issue, I found this thread from 7+ years

https://yabb.jriver.com/interact/index.php/topic,89149.msg612157.html

that basically said (as I read it) that MC treats nulls and zeroes in integer fields as the same (which they're not).  Because MC is still behaving that way, I presume this was never considered an issue that needed to be "fixed".  Can anyone shed some light on recent thinking about this?  Is there any hope of seeing a zero as a value in an integer field?

Thx - Bill
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2398
Re: Does zero still equal null?
« Reply #1 on: January 03, 2022, 04:58:01 am »

As a workaround, you can add an Expression field or column to map an empty value to a zero string:
Code: [Select]
=firstnotempty([Number Plays],0)
You can then use that new Field in Views instead of the original field (though it can't be edited, only the original field is editable)
Logged

wburkett

  • World Citizen
  • ***
  • Posts: 109
Re: Does zero still equal null?
« Reply #2 on: January 03, 2022, 09:18:17 pm »

Thanks, zybex ... the work around simply means that I need two fields instead of one. 

I've managed this long without a Zero, so I'll just keep managing, I guess.

Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2398
Re: Does zero still equal null?
« Reply #3 on: January 04, 2022, 04:18:06 am »

A retired legend explained to me that an Int field does indeed store the zero value, but the default MC way of showing fields is with the 'Formatted' flag enabled. When a field is shown or used in an expression like [Number Plays], the default mode is actually [Number Plays, 1] which means the formatted value is displayed - zeros are suppressed for integers, dates are shown as human readable, etc.

This means that you could also use [Number Plays, 0] to show zeroes. Or the equivalent Field(Number Plays, 0).
https://wiki.jriver.com/index.php/Accessing_and_Storing_Functions#Field.28.E2.80.A6.29

@Matt: Here's an idea for a new feature - show a checkbox in the field definition to select "show unformatted value" by default.
Logged
Pages: [1]   Go Up