473,385 Members | 1,465 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,385 software developers and data experts.

Calculate averages but exclude "null" months and include when a "0" is shown

547 512MB
Adezii kindly helped me with the following code many months ago when i wanted to exclude months that showed a "0" value issued to patients for that month.
It now works like this: when the supplier has no stock and nothing was issued to patients during a month, then we are going to add 99999 (or should we make it blank perhaps? i will prefer that) in the quantity field.

If nothing was issued to patients during a month but we had stock on hand, then i will use "0" in the quantity field.
I need to calculate the average using this criteria for a period

Expand|Select|Wrap|Line Numbers
  1. Result: FormatNumber((DSum("[Quantity]","tblAcquire","[Quantity]>0"))/(DCount("[Month]","tblAcquire","[Quantity]>0")),2)
Expand|Select|Wrap|Line Numbers
  1. month     Quantity
  2. 1            20
  3. 2            99999  or leave blank?
  4. 3             0
  5. 4             18
  6. 5             99999  or leave blank?
Please assist
Sep 25 '13 #1
3 1216
zmbd
5,501 Expert Mod 4TB
Personally, I would leave the field empty (blank) so if you used a totals query, the average() will not include the empty fields in the calculation. Otherwise you will have to have a ton of code to handle the 99999.

The zero would be counted and included in the Average() in a totals query.
Sep 25 '13 #2
neelsfer
547 512MB
thx zmbd.This is then straight forward. I will add the date but leave the quantity blank. As is understand it, i dont have to include anything to ignore blank fields when calculating averages?
Sep 25 '13 #3
zmbd
5,501 Expert Mod 4TB
You shouldn't have to add anything.
Sep 25 '13 #4

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

Similar topics

16
by: sandy | last post by:
Hi, Using Java script I am trying to create code where when you place in the start date it automatically calculates 6 months for the experations date. For example when I place 01/01/04 as the...
2
by: lpeterson | last post by:
I'm trying to calculate the number of months between dates that begin in 2003 and end in 2004(ex. 1/2/2003 - 7/2/2004). I need the total months in 2003 and in 2004 both of which should add up to...
6
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns...
2
by: ljlevend | last post by:
I have a file path (i.e., String) property that uses a System.Windows.Forms.Design.FileNameEditor as its System.ComponentModel.Editor. This property is exposed by a PropertyGrid. What I need to...
5
by: Michael.Suarez | last post by:
Suppose I have a button on a form that opens up another form. the code in the buttons click event is: frmMyCustomForm frm = new frmMyCustomForm (); frm.ShowDialog(); frm.Dispose(); The...
2
by: nickvans | last post by:
Hello everyone! I have a question that should be rather simple, but I haven't been able to figure out a way to do it. I have a table which has assembly numbers, and another table with parts...
2
by: johanneguaybenoit | last post by:
Hi I would like to know how to create a function or module to calculate the age of a person in years months days. and hours if feasable But I really nead to know in years months days. I...
5
by: abhishekmoon007 | last post by:
the program should accept the current date, month and year and should calculate 1 year later date.
7
by: AL Engineer | last post by:
Hello All, I am using access 2007 to record the date and quantity of a product when it is staged on our production floor. I know when the first quantity is consumed when the next record is...
5
by: neelsfer | last post by:
Its easy to calculate averages in Access queries using the Totals method, but what do you do in the following instance? month-------quantity 1 ------------10 2-------------0 3-------------20...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.