473,385 Members | 1,275 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.

Standard Deviations in Microsoft Access

I'm trying to calculate a standard deviation for each record in a database...the record has 12 fields which contain consumption for each month of the year. I want to calculate the standard deviation of those 12 fields but it seems like access is wanting to calculate only on one field...
Is there any way around this or am I just not understanding how it works?
I'm fairly new to access and don't know anything about VB and some of the sql statements...
Oct 25 '07 #1
9 23410
puppydogbuddy
1,923 Expert 1GB
I'm trying to calculate a standard deviation for each record in a database...the record has 12 fields which contain consumption for each month of the year. I want to calculate the standard deviation of those 12 fields but it seems like access is wanting to calculate only on one field...
Is there any way around this or am I just not understanding how it works?
I'm fairly new to access and don't know anything about VB and some of the sql statements...
The following link should enable you to solve your problem:

http://support.microsoft.com/kb/209839
Oct 25 '07 #2
The following link should enable you to solve your problem:

http://support.microsoft.com/kb/209839
Thank you for the response but VB is not something I've ever used. Do I just cut-n-paste the module code into my database? Or do I need to change something in it's coding?
Oct 25 '07 #3
FishVal
2,653 Expert 2GB
I'm trying to calculate a standard deviation for each record in a database...the record has 12 fields which contain consumption for each month of the year. I want to calculate the standard deviation of those 12 fields but it seems like access is wanting to calculate only on one field...
Is there any way around this or am I just not understanding how it works?
I'm fairly new to access and don't know anything about VB and some of the sql statements...
Hi, there.

You have two options:
  • within a query you may use StDev or StDevP aggregate functions
  • in VBA you may use DStDev or DStDevP domain aggregate functions
Oct 25 '07 #4
Hi, there.

You have two options:
  • within a query you may use StDev or StDevP aggregate functions
  • in VBA you may use DStDev or DStDevP domain aggregate functions
The StDev or StDevP seems to only work on one field within a record where I want to look at 12 fields which are by month. I attempted to use it but it won't recognize more than 1 field....or so it seems.

Example: I have a material number and then usage for Jan, Feb, Mar, Apr, May, thru Dec. I want to find the Std Deviation for those 12 months of data.
Oct 25 '07 #5
FishVal
2,653 Expert 2GB
The StDev or StDevP seems to only work on one field within a record where I want to look at 12 fields which are by month. I attempted to use it but it won't recognize more than 1 field....or so it seems.

Example: I have a material number and then usage for Jan, Feb, Mar, Apr, May, thru Dec. I want to find the Std Deviation for those 12 months of data.
That is because you have an improper table structure. Month usage should be in different records, not in different fields.
Take a look at Database Normalisation and Table structures tutorial.

If you are not willing to reorganize your tables structure, then read this stuff.
Oct 25 '07 #6
puppydogbuddy
1,923 Expert 1GB
Thank you for the response but VB is not something I've ever used. Do I just cut-n-paste the module code into my database? Or do I need to change something in it's coding?
FishVal's comments about normalization are valid, and should be implemented in your database. However, I believe the functions included in the link will enable you to do the computations you want using your existing database structure, although I have not personally used them.

Just cut-n-paste the module code in your database, and compile it. then you will be able to call the included functions and pass arrays consisting of your column(field) values. The included functions utilize the statistical function options mentioned by Fish. Hope this helps.
Oct 26 '07 #7
ADezii
8,834 Expert 8TB
I'm trying to calculate a standard deviation for each record in a database...the record has 12 fields which contain consumption for each month of the year. I want to calculate the standard deviation of those 12 fields but it seems like access is wanting to calculate only on one field...
Is there any way around this or am I just not understanding how it works?
I'm fairly new to access and don't know anything about VB and some of the sql statements...
  1. Copy and Paste the following Function to a Standard Code Module:

    Expand|Select|Wrap|Line Numbers
    1. Public Function RStDev(ParamArray FieldValues()) As Variant
    2.  
    3. '---------------------------------------------------------
    4.  
    5. ' Function RStDev() calculates the Standard Deviation of
    6.  
    7. ' sample data passed as arguments. NOTE: The standard deviation
    8.  
    9. ' of sample data is only valid if more than one argument is
    10.  
    11. ' numeric.
    12.  
    13. '---------------------------------------------------------
    14.  
    15. Dim dblSum As Double, dblSumOfSq As Double
    16.  
    17. Dim n As Long, varArg As Variant
    18.  
    19. For Each varArg In FieldValues
    20.  
    21.   If IsNumeric(varArg) Then
    22.  
    23.     dblSum = dblSum + varArg
    24.  
    25.     dblSumOfSq = dblSumOfSq + varArg * varArg
    26.  
    27.       n = n + 1
    28.  
    29.   End If
    30.  
    31. Next
    32.  
    33.  
    34.  
    35. If n > 1 Then ' Variance/StDev applies if more than a single point
    36.  
    37.   RStDev = Sqr((n * dblSumOfSq - dblSum * dblSum) / (n * (n - 1)))
    38.  
    39. Else
    40.  
    41.   RStDev = Null
    42.  
    43. End If
    44.  
    45. End Function
  2. Make you own modifications, but for test purposes I created a Table named tblStandardDeviation.
  3. tblStandardDeviation consists of an [ID] Field (Primary Key){AutoNumber}, and 12 Fields named [Field1] through [Field12]. Set the Data Type of these Fields to Double.
  4. Create the following Query, substituting your Field Names for the generic [Field1] through [Field12].

    Expand|Select|Wrap|Line Numbers
    1. SELECT Val(RStDev([Field1],[Field2],[Field3],[Field4],[Field5],[Field6], [Field7],[Field8],[Field9],[Field10],[Field11],[Field12])) AS Std_Deviation
    2.  
    3. FROM tblStandardDeviation;
  5. I do believe that you will arrive at the correct results.
  6. Please give puppydogbuddy the credit for this one, he pointed you in the right direction with the proper Link. I just followed in his footsteps and implemented what he had already found.
NOTE: As indicated in the Link, Microsoft Access has several built-in functions that enable you to perform statistical analysis across Records, it does not have a built-in function to perform statistical analysis across multiple columns within a single row. This is why the need for a Custom Function to perform this task.
Oct 26 '07 #8
puppydogbuddy
1,923 Expert 1GB
ADezii,
Thanks for confirming the validity and relevance of info that I provided, and for the excellent job you did of filling in the missing detail that I was not familiar with.

pDog
Oct 26 '07 #9
ADezii
8,834 Expert 8TB
ADezii,
Thanks for confirming the validity and relevance of info that I provided, and for the excellent job you did of filling in the missing detail that I was not familiar with.

pDog
Always a pleasure working with a fellow Expert.
Oct 26 '07 #10

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

Similar topics

8
by: wlcna | last post by:
mysql v4.0.16: I had been using mysql with innodb and thought that was fine, until i used it for something requiring a few - perhaps slightly involved - joins, and have now seen the performance...
0
by: alisae | last post by:
Hello. I have a HP6630 Computer, Windows Xp Professional, Office Xp Standard Edition and a standalone version of Microsoft Access 2000 sr1 on a separate cdrom. The problem is every time I want to...
2
by: Skipper_23 | last post by:
can anyone help me out, how to use multiple tables in one form using microsoft access?
17
by: Pam Ammond | last post by:
I need to use Microsoft Access Automation within a Visual Studio 2003 program written in C# for Windows Forms. When a button is clicked in my VS.NET program, I want it to run a Microsoft Access...
2
by: Andrew S. Giles | last post by:
OK, I am trying to prototype a data import function, and the Data Import Wizard from Microsoft Access is what we wanted to pattern our importer off of. How do I get to this wizard inside the...
4
by: bbdobuddy | last post by:
Hi, How do I open a Microsoft Access 2003 form from Visual Basic.net Thanks in advance bbdobuddy
1
by: somersbar | last post by:
hey, ive been trying to set up a web form in visual basic.net that can access a microsoft access database. i need to use odbc also. i can get it working using a windows form but not a web form....
5
by: somersbar | last post by:
hello all, im trying to connect to a microsoft access database from an ASP.NET web form. i keep getting the following error though: ERROR Could not use '(unknown)'; file already in use....
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
2
by: Dave Smith | last post by:
I was assuming that this would be something I could find on the web, but I'm just not finding it I'm not. How would I get I use a query to get the Standard Deviations? From what I read it should...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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...
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.