{"id":106,"date":"2009-06-10T13:51:29","date_gmt":"2009-06-10T18:51:29","guid":{"rendered":"http:\/\/www.teamdesk.net\/blog\/2009\/06\/handle-nulls-and-div-by-zero\/"},"modified":"2015-10-26T14:33:31","modified_gmt":"2015-10-26T19:33:31","slug":"handle-nulls-and-div-by-zero","status":"publish","type":"post","link":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/","title":{"rendered":"New way to handle NULLs and divisions by zero"},"content":{"rendered":"<p style=\"font-family: Verdana;\">&#8230;that&#8217;s what we were working on over past couple of months.<\/p>\n<p>When performing numeric calculations TeamDesk used to distinguish between NULL (that&#8217;s when user left input field blank) and zero. NULL is a special value that does not compare to anything and requires special form of check for it. Moreover result of any arithmetical operation with NULL is also NULL and here we received a lot of questions like &#8220;I&#8217;m using the formula [A]+[B]+[C] and the result is blank value, why?&#8221; The answer is simple: A (or B or C) is blank. Ok, but for non-techie user it&#8217;s a bit hard to understand.<\/p>\n<p>We had an option that control NULL behavior during the calculations, called &#8220;Blank as zero&#8221; that substituted NULL values with zeros during the calculations but this option was often turned off.<\/p>\n<p>Another reoccurring problem\u00a0was the division by zero error. It&#8217;s not a secret we are performing calculations using underlying database engine (namely, Microsoft SQL Server) and when first division by zero is encountered, it stops data extraction immediately returning the error message. Unfortunately, without any kind of location information. So user ended up with &#8220;Division by zero&#8221; message on screen with small chance to guess the formula that caused the error to fix it.<\/p>\n<p>Finally we decided to address both problems at once.<\/p>\n<p><!--more--><\/p>\n<p>For new TeamDesk applications <strong>numerical NULL values are always handled like zeros<\/strong>. Period. As the result, the formula can not result to NULL, since you can not produce it performing arithmetical operations. This behavior is quite similar to the spreadsheet calculations. Lookups, summaries and functions that convert from non-numeric types to numeric result to zero on blank input.<\/p>\n<p>Division by zero now generate <strong style=\"color: #800000;\">DIV\/0 <\/strong>designator to the cell where error occurred. All subsequent calculations on such a value will also produce DIV\/0. As a bonus, we are also generating <strong style=\"color: #800000;\">ERR<\/strong> message for the formulas that do not compile.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.teamdesk.net\/blog\/wp-content\/uploads\/2009\/06\/621.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-502\" src=\"https:\/\/www.teamdesk.net\/blog\/wp-content\/uploads\/2009\/06\/621.gif\" alt=\"62,1\" width=\"270\" height=\"89\" \/><\/a><\/p>\n<p>For those of you who are curious how it&#8217;s done and how it affects the performance, keep in mind that a) you can not produce NULL with TeamDesk formulas and b) any database-level arithmetical operation with NULL produce NULL. So, now, in calculations we are using NULL as a designator of division by zero error. You may have achieve the same result before, but you had to keep in mind all those checks for NULLs and zeroes and now TeamDesk does all this for you automatically. We hope you will like it.<\/p>\n<p>Since TeamDesk&#8217;s duration type is similar to numeric all said above applies to durations as well.<\/p>\n<p>Below is the list of changes we did to implement these features:<\/p>\n<p>Numerical versions of <span style=\"font-family: Courier New;\">Nz(), IsNull(), NullIf()<\/span> functions are dropped as their arguments can&#8217;t calculate to NULL.<\/p>\n<p>Functions and operators, converting\/calculating\u00a0from other types to numeric will return zero on NULL input. These are <span style=\"font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;\">ToNumber(), Len(), Day(), DayOfWeek(), DayOfYear(), Month(), Quarter(), Year(), Hour(), Minute(), Second() <\/span>and subtraction operators <span style=\"font-family: Courier New;\">date &#8211; date, time &#8211; time, timestamp &#8211; timestamp.<\/span><\/p>\n<p><span style=\"font-family: Courier New;\">Sum(a, b, c) <\/span>is left for compatibility but identical to <span style=\"font-family: Courier New;\">a + b + c.<\/span><\/p>\n<p><span style=\"font-family: Courier New;\">If() and Case() <\/span>functions resulting to numeric and with omitted\u00a0\u00a0arguments will return 0 instead of NULL.<\/p>\n<p>Numeric summary columns will result to 0 when there are no records to calculate on.<\/p>\n<p>Please note that new applications\u00a0created from scratch and from templates in application\u00a0library use new logic by default.<\/p>\n<p>For now, existing applications continue to use old logic. Any copy made from such app will\u00a0use old logic as well.<\/p>\n<p>While our ultimate goal is to get rid of old code, we undestand that this change heavily affects the compatibility and migration to the new logic will need careful review and will take some time.\u00a0We are planning to announce formula analysis tools to ease the migration in a next few days.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8230;that&#8217;s what we were working on over past couple of months. When performing numeric calculations TeamDesk used to distinguish between NULL (that&#8217;s when user left input field blank) and zero. NULL is a special value that does not compare to anything and requires special form of check for it. Moreover result of any arithmetical operation [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-106","post","type-post","status-publish","format-standard","hentry","category-whats-new"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>New way to handle NULLs and divisions by zero - TeamDesk Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"New way to handle NULLs and divisions by zero - TeamDesk Blog\" \/>\n<meta property=\"og:description\" content=\"&#8230;that&#8217;s what we were working on over past couple of months. When performing numeric calculations TeamDesk used to distinguish between NULL (that&#8217;s when user left input field blank) and zero. NULL is a special value that does not compare to anything and requires special form of check for it. Moreover result of any arithmetical operation [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/\" \/>\n<meta property=\"og:site_name\" content=\"TeamDesk Blog\" \/>\n<meta property=\"article:published_time\" content=\"2009-06-10T18:51:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-10-26T19:33:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.teamdesk.net\/blog\/wp-content\/uploads\/2009\/06\/621.gif\" \/>\n<meta name=\"author\" content=\"Kirill Bondar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirill Bondar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/\"},\"author\":{\"name\":\"Kirill Bondar\",\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/#\\\/schema\\\/person\\\/22c4c05bd657513c8b00122fa364c8d2\"},\"headline\":\"New way to handle NULLs and divisions by zero\",\"datePublished\":\"2009-06-10T18:51:29+00:00\",\"dateModified\":\"2015-10-26T19:33:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/\"},\"wordCount\":639,\"commentCount\":3,\"image\":{\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/06\\\/621.gif\",\"articleSection\":[\"What's New\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/\",\"url\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/\",\"name\":\"New way to handle NULLs and divisions by zero - TeamDesk Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/06\\\/621.gif\",\"datePublished\":\"2009-06-10T18:51:29+00:00\",\"dateModified\":\"2015-10-26T19:33:31+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/#\\\/schema\\\/person\\\/22c4c05bd657513c8b00122fa364c8d2\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/06\\\/621.gif\",\"contentUrl\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/06\\\/621.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/whats-new\\\/handle-nulls-and-div-by-zero\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"New way to handle NULLs and divisions by zero\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/\",\"name\":\"TeamDesk Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/#\\\/schema\\\/person\\\/22c4c05bd657513c8b00122fa364c8d2\",\"name\":\"Kirill Bondar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc5bc844095b5753ccc73c589c028bf16615674f289668146bbd59205a08a52d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc5bc844095b5753ccc73c589c028bf16615674f289668146bbd59205a08a52d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc5bc844095b5753ccc73c589c028bf16615674f289668146bbd59205a08a52d?s=96&d=mm&r=g\",\"caption\":\"Kirill Bondar\"},\"url\":\"https:\\\/\\\/www.teamdesk.net\\\/blog\\\/author\\\/kirill-bondar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"New way to handle NULLs and divisions by zero - TeamDesk Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/","og_locale":"en_US","og_type":"article","og_title":"New way to handle NULLs and divisions by zero - TeamDesk Blog","og_description":"&#8230;that&#8217;s what we were working on over past couple of months. When performing numeric calculations TeamDesk used to distinguish between NULL (that&#8217;s when user left input field blank) and zero. NULL is a special value that does not compare to anything and requires special form of check for it. Moreover result of any arithmetical operation [&hellip;]","og_url":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/","og_site_name":"TeamDesk Blog","article_published_time":"2009-06-10T18:51:29+00:00","article_modified_time":"2015-10-26T19:33:31+00:00","og_image":[{"url":"https:\/\/www.teamdesk.net\/blog\/wp-content\/uploads\/2009\/06\/621.gif","type":"","width":"","height":""}],"author":"Kirill Bondar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirill Bondar","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/#article","isPartOf":{"@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/"},"author":{"name":"Kirill Bondar","@id":"https:\/\/www.teamdesk.net\/blog\/#\/schema\/person\/22c4c05bd657513c8b00122fa364c8d2"},"headline":"New way to handle NULLs and divisions by zero","datePublished":"2009-06-10T18:51:29+00:00","dateModified":"2015-10-26T19:33:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/"},"wordCount":639,"commentCount":3,"image":{"@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/#primaryimage"},"thumbnailUrl":"https:\/\/www.teamdesk.net\/blog\/wp-content\/uploads\/2009\/06\/621.gif","articleSection":["What's New"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/","url":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/","name":"New way to handle NULLs and divisions by zero - TeamDesk Blog","isPartOf":{"@id":"https:\/\/www.teamdesk.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/#primaryimage"},"image":{"@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/#primaryimage"},"thumbnailUrl":"https:\/\/www.teamdesk.net\/blog\/wp-content\/uploads\/2009\/06\/621.gif","datePublished":"2009-06-10T18:51:29+00:00","dateModified":"2015-10-26T19:33:31+00:00","author":{"@id":"https:\/\/www.teamdesk.net\/blog\/#\/schema\/person\/22c4c05bd657513c8b00122fa364c8d2"},"breadcrumb":{"@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/#primaryimage","url":"https:\/\/www.teamdesk.net\/blog\/wp-content\/uploads\/2009\/06\/621.gif","contentUrl":"https:\/\/www.teamdesk.net\/blog\/wp-content\/uploads\/2009\/06\/621.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/www.teamdesk.net\/blog\/whats-new\/handle-nulls-and-div-by-zero\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.teamdesk.net\/blog\/"},{"@type":"ListItem","position":2,"name":"New way to handle NULLs and divisions by zero"}]},{"@type":"WebSite","@id":"https:\/\/www.teamdesk.net\/blog\/#website","url":"https:\/\/www.teamdesk.net\/blog\/","name":"TeamDesk Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.teamdesk.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.teamdesk.net\/blog\/#\/schema\/person\/22c4c05bd657513c8b00122fa364c8d2","name":"Kirill Bondar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dc5bc844095b5753ccc73c589c028bf16615674f289668146bbd59205a08a52d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dc5bc844095b5753ccc73c589c028bf16615674f289668146bbd59205a08a52d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc5bc844095b5753ccc73c589c028bf16615674f289668146bbd59205a08a52d?s=96&d=mm&r=g","caption":"Kirill Bondar"},"url":"https:\/\/www.teamdesk.net\/blog\/author\/kirill-bondar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":1,"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":503,"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/posts\/106\/revisions\/503"}],"wp:attachment":[{"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.teamdesk.net\/blog\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}