PC Review


Reply
Thread Tools Rate Thread

average of data

 
 
new kid
Guest
Posts: n/a
 
      26th Apr 2009
I have a query that seems to work only sometimes, and cannot seem to pin down
why:

UPDATE AVGBAL SET [SIX MO AVG] = IIf(ISNULL([AVGBAL.mar09]) And
ISNULL([AVGBAL.feb09]) And ISNULL([AVGBAL.jan09]) And ISNULL([AVGBAL.dec08])
And ISNULL([AVGBAL.nov08]) And
ISNULL([AVGBAL.oct08]),yy0,(NZ([AVGBAL.mar09])+NZ([AVGBAL.feb09])+NZ([AVGBAL.jan09])+NZ([AVGBAL.dec08])+NZ([AVGBAL.nov08])+([AVGBAL.oct08]))/(IIf(ISNULL([AVGBAL.mar09]),0,1)+IIf(ISNULL([AVGBAL.feb09]),0,1)+IIf(ISNULL([AVGBAL.jan09]),0,1)+IIf(ISNULL([AVGBAL.dec08]),0,1)+IIf(ISNULL([AVGBAL.nov08]),0,1)+IIf(ISNULL([AVGBAL.oct08]),0,1)));
 
Reply With Quote
 
 
 
 
KARL DEWEY
Guest
Posts: n/a
 
      27th Apr 2009
A couple of things -- What is 'yy0'?
You can not average averages as you are trying to do
Mathematically you can not do it.
Average 50, 50, & 50 = 50. Average 10, 100, 50, 50, and 75 = 57

Average 50 & 57 = 53.5
Average 50, 50, & 50, 10, 100, 50, 50, and 75 = 54.375

You must use the root data to find the correct average.

You have your table laid out like a spreadsheet -- that is a no, no.
Use a union query to put your data in a 'normalized' table.

And finally, DO NOT STORE calculated information as the data it is derived
from may change and therefore the calculation will be wrong. Always compute
it when needed to ensure current data,

"new kid" wrote:

> I have a query that seems to work only sometimes, and cannot seem to pin down
> why:
>
> UPDATE AVGBAL SET [SIX MO AVG] = IIf(ISNULL([AVGBAL.mar09]) And
> ISNULL([AVGBAL.feb09]) And ISNULL([AVGBAL.jan09]) And ISNULL([AVGBAL.dec08])
> And ISNULL([AVGBAL.nov08]) And
> ISNULL([AVGBAL.oct08]),yy0,(NZ([AVGBAL.mar09])+NZ([AVGBAL.feb09])+NZ([AVGBAL.jan09])+NZ([AVGBAL.dec08])+NZ([AVGBAL.nov08])+([AVGBAL.oct08]))/(IIf(ISNULL([AVGBAL.mar09]),0,1)+IIf(ISNULL([AVGBAL.feb09]),0,1)+IIf(ISNULL([AVGBAL.jan09]),0,1)+IIf(ISNULL([AVGBAL.dec08]),0,1)+IIf(ISNULL([AVGBAL.nov08]),0,1)+IIf(ISNULL([AVGBAL.oct08]),0,1)));

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I average hourly data into daily data? Lindsey Microsoft Excel Misc 1 30th Mar 2009 05:05 PM
Average when No Data =?Utf-8?B?Y2FybA==?= Microsoft Excel Worksheet Functions 4 13th Jan 2006 07:39 PM
How do you average if your data contains a 0? =?Utf-8?B?cmFzNzEx?= Microsoft Excel Worksheet Functions 14 8th Nov 2005 03:55 AM
Average only if there is data That's Confidential Microsoft Excel Misc 3 20th Mar 2004 10:38 AM
Trying to aggregate weekly data into monthly average data Karen 1144 Microsoft Excel Misc 4 6th Nov 2003 12:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:20 AM.