473,395 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can't add properly in Expression

I have a table with columns A, B, C, D. In column E, I have an expression that says Expn 1: [A] + [b] + [C] + [D]. Some records in columns A, B, C, D have null values. When I run the query, only records with non-null values in all four A-D columns will add. If there are one or more non-null values in any of the A-D columns, column E will also return as null. Any one know a solution for this?
Oct 12 '10 #1
3 1230
dsatino
393 256MB
There's a bunch of ways to handle this, so you may want to wait for other responses as well, but here's one way:

IIF(nz([A],0)=0,0,[A])+ IIF(nz([b],0)=0,0,[b])+ .....

Basically, it tests for Null and if it finds a field to be null it simply uses 0.
Oct 12 '10 #2
Mariostg
332 100+
Also, you may want to consider modifying your table design to default values to 0 when new records are created. So if only A and B are filled in, the others will have zeros.
Oct 12 '10 #3
NeoPa
32,556 Expert Mod 16PB
I presume your column E is in a non-stated query rather than the table?

If so, Mario's advice is probably the most straightforward, but alternatively you could say :
Expand|Select|Wrap|Line Numbers
  1. E: Nz([A],0) + Nz([b],0) + Nz([C],0) + Nz([D],0)
Oct 12 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sarah E. Green | last post by:
I'm well familiar with both PHP and Perl Let's say you've written, or have access to, a nice set of PHP modules or functions which allow you to write general applications very quickly. (As an...
1
by: Gareth James via .NET 247 | last post by:
I have an expression that when run uses 100% cpu for over 1minute. I can change the expression so this does not happen, but couldsome one explain why this happens so that I don't do it again ...
2
by: Mike Turco | last post by:
I like using the expression builder for a lot of different things but it isn't always available when I want to use it, for example in the code window, or in all of the control properties. I am...
9
by: MJ | last post by:
HI I want to know what is mean by regular expression in C Mayur
11
by: Dimitris Georgakopuolos | last post by:
Hello, I have a text file that I load up to a string. The text includes certain expression like {firstName} or {userName} that I want to match and then replace with a new expression. However,...
2
by: Steve Gelfmann | last post by:
Hi, I have a problem running ASP.NET applications that recently started to only work when they contain static HTML tags, everything else like <script> or directives are not executed. I used to be...
8
by: Daniel R. Rossnagel | last post by:
Sample: String c="1+2+3" since it can makes to obtain the value of this Expression? Other Sample: Int X=4 String c="1+2+3+X "
17
by: Grizlyk | last post by:
Hello. What can be optimised in C++ code and how i can garantee stable behaviour below 1. Are expression "auto volatile" can deny removing as "unused temporary" like this: auto volatile...
15
by: Ronald S. Cook | last post by:
We have graphics/web designers at our firm and then programmers. We're trying to work together without stepping on each other's toes. So far, we've all been using Visual Studio. But, is there...
15
by: Matt | last post by:
Hi There, Can anyone explain me the real advantages of (other than syntax) lambda expressions over anonymous delegates? advantage for one over the other. delegate int F(int a); F fLambda = a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.