SUMIF/COUNTIF with missing data

Right now, I'm using the following function to get the average of column B, 
given that column A has a certain criteria:


=SUMIF($A$1:$A$10,"=Blue",$B$1:$B$10)/COUNTIF($A$1:$A$10,"=Blue")

Which works fine, except that for some of the entries whose A column says 
"blue" there is no data in the B column, so the denominator is off. How can I 
account for missing data in this function?

Thanks in advance.
0
Utf
12/22/2009 4:43:01 PM
excel.worksheet.functions 4936 articles. 2 followers. Follow

4 Replies
1388 Views

Similar Articles

[PageSpeed] 2

Try

=SUMIF($A$1:$A$10,"Blue",$B$1:$B$10)/SUMPRODUCT(($A$1:$A$10="Blue")
*(B1:B10<>""))

OR  try the below array formula. You create array formulas in the same way 
that you create other formulas, except you press CTRL+SHIFT+ENTER to enter 
the formula. If successful in 'Formula Bar' you can notice the curly braces 
at both ends like "{=<formula>}"

=AVERAGE(IF(A1:A10="Blue",IF(B1:B10<>"",B1:B10)))

-- 
Jacob


"AAA1986" wrote:

> Right now, I'm using the following function to get the average of column B, 
> given that column A has a certain criteria:
> 
> 
> =SUMIF($A$1:$A$10,"=Blue",$B$1:$B$10)/COUNTIF($A$1:$A$10,"=Blue")
> 
> Which works fine, except that for some of the entries whose A column says 
> "blue" there is no data in the B column, so the denominator is off. How can I 
> account for missing data in this function?
> 
> Thanks in advance.
0
Utf
12/22/2009 4:53:02 PM
Try this array formula** :

=AVERAGE(IF(A1:A10="blue",IF(B1:B10<>"",B1:B10)))

** array formulas need to be entered using the key combination of 
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT 
key then hit ENTER.

-- 
Biff
Microsoft Excel MVP


"AAA1986" <AAA1986@discussions.microsoft.com> wrote in message 
news:24D0D2E9-25A8-413E-8263-519B6D6952AC@microsoft.com...
> Right now, I'm using the following function to get the average of column 
> B,
> given that column A has a certain criteria:
>
>
> =SUMIF($A$1:$A$10,"=Blue",$B$1:$B$10)/COUNTIF($A$1:$A$10,"=Blue")
>
> Which works fine, except that for some of the entries whose A column says
> "blue" there is no data in the B column, so the denominator is off. How 
> can I
> account for missing data in this function?
>
> Thanks in advance. 


0
T
12/22/2009 4:58:47 PM
Thanks! The first one works great. But what's the difference between the 
first one and the array one? Is there any reason I should use one instead of 
the other?

"Jacob Skaria" wrote:

> Try
> 
> =SUMIF($A$1:$A$10,"Blue",$B$1:$B$10)/SUMPRODUCT(($A$1:$A$10="Blue")
> *(B1:B10<>""))
> 
> OR  try the below array formula. You create array formulas in the same way 
> that you create other formulas, except you press CTRL+SHIFT+ENTER to enter 
> the formula. If successful in 'Formula Bar' you can notice the curly braces 
> at both ends like "{=<formula>}"
> 
> =AVERAGE(IF(A1:A10="Blue",IF(B1:B10<>"",B1:B10)))
> 
> -- 
> Jacob
> 
> 
> "AAA1986" wrote:
> 
> > Right now, I'm using the following function to get the average of column B, 
> > given that column A has a certain criteria:
> > 
> > 
> > =SUMIF($A$1:$A$10,"=Blue",$B$1:$B$10)/COUNTIF($A$1:$A$10,"=Blue")
> > 
> > Which works fine, except that for some of the entries whose A column says 
> > "blue" there is no data in the B column, so the denominator is off. How can I 
> > account for missing data in this function?
> > 
> > Thanks in advance.
0
Utf
12/22/2009 7:10:01 PM
The 1st one is a bit lenghty; but I would prefer the 1st one..

-- 
Jacob


"AAA1986" wrote:

> Thanks! The first one works great. But what's the difference between the 
> first one and the array one? Is there any reason I should use one instead of 
> the other?
> 
> "Jacob Skaria" wrote:
> 
> > Try
> > 
> > =SUMIF($A$1:$A$10,"Blue",$B$1:$B$10)/SUMPRODUCT(($A$1:$A$10="Blue")
> > *(B1:B10<>""))
> > 
> > OR  try the below array formula. You create array formulas in the same way 
> > that you create other formulas, except you press CTRL+SHIFT+ENTER to enter 
> > the formula. If successful in 'Formula Bar' you can notice the curly braces 
> > at both ends like "{=<formula>}"
> > 
> > =AVERAGE(IF(A1:A10="Blue",IF(B1:B10<>"",B1:B10)))
> > 
> > -- 
> > Jacob
> > 
> > 
> > "AAA1986" wrote:
> > 
> > > Right now, I'm using the following function to get the average of column B, 
> > > given that column A has a certain criteria:
> > > 
> > > 
> > > =SUMIF($A$1:$A$10,"=Blue",$B$1:$B$10)/COUNTIF($A$1:$A$10,"=Blue")
> > > 
> > > Which works fine, except that for some of the entries whose A column says 
> > > "blue" there is no data in the B column, so the denominator is off. How can I 
> > > account for missing data in this function?
> > > 
> > > Thanks in advance.
0
Utf
12/23/2009 5:36:01 AM
Reply:

Similar Artilces:

WM_QUERYENDSESSION and saving data through a worker thread
Hello I have an application that uses a worker thread to save/load data. I'm wondering what is the best reaction to WM_QUERYENDSESSION in my case. I have to possible scenarios: 1. When WM_QUERYENDSESSION comes fire the thread and wait for it to end. Only then return TRUE from WM_QUERYENDSESSION handler. The problem is that I will get nusty dialog that my application "is not responding". 2. When WM_QUERYENDSESSION comes fire the thread and return FALSE from the handler. When thread is done force application to end. But this way I will probably prevent Windows from closing,...

Copying data from one chart to another
I have many graphs - all plotting on similar scales but using different data. Is there any way I can simply copy one set of data from one graph and paste it into another graph so that I can avoind going through all the hassle plotting each curve again? I want to have graphs showing different combinations of the same data and have hundreds of curves to plot so this could be a huge timesaver... Cheers. -- Alan_Partridge ------------------------------------------------------------------------ Alan_Partridge's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29295 V...

Can I abbreviate one value in a data series?
I've got a chart where one value (8,300) greatly exceeds all the others. Is there a way to abbreviate this value so the other data points show better in the graph? Hi, One way is to break the Y axis, have a look at these examples of how to http://peltiertech.com/Excel/Charts/BrokenYAxis.html http://tushar-mehta.com/excel/newsgroups/broken_y_axis/tutorial/index.html http://www.andypope.info/charts/brokencolumn.htm Cheers Andy CMEknit wrote: > I've got a chart where one value (8,300) greatly exceeds all the others. Is > there a way to abbreviate this value so the other da...

How can I clear the last Data->Text to columns to formatting
I've noticed in Excel 2000 that if I paste text into various worksheets within a workbook each paste will assume the Text->Column formatting that I applied in the previous. How can I prevent it from happening ? Thanks Steve Just run another data|Text to columns against a dummy cell. Specify delimited, but remove all the check marks from all the possible delimiters. (alternatively, you can close excel and reopen it.) svaardt wrote: > > I've noticed in Excel 2000 that if I paste text into various worksheets > within a workbook each paste will assume the Text->Col...

Missing transactions?
In my Account List view, I see that there are "Transactions to read: 13" for my checking account. However, when I go to my checking account, there are no unread transactions! Note that I do have "View: All Transactions covering All Dates" selected as the view, so I would expect to see all of the transactions. I've been using MS Money for years, and this is the first time this problem has come up. Does anyone have any suggestions on how to resolve this? Thanks, DJ You could try deleting the statement from the account list, right click where it says 'X tr...

Where to get missing msvcp70.dll?
After I uninstalled a bunch of software, when I run an app it says app failed because msvcp70.dll was not found. Re-installing that app does not help. I guess I need to restore the missing msvcp70.dll. What is the official way to get it? Some sites offer this file for download but I'm not sure the files are genuine. In my system32 folder there is msvcp50.dll, msvcp60.dll, msvcp71.dll, but no msvcp70.dll. It is not in the recycle bin either :( "james" <nospam@nospam.com> wrote in message news:#XS21G1gKHA.5520@TK2MSFTNGP06.phx.gbl... > After I un...

How do I import data from lotus123 & maintain formulas/worksheets
I am trying to convert several complex Lotus 123 workbooks with formulas into Excel 2003. How do I do this and maintain my formulas and the individual tabs (worksheets). hi, if the lotus file is a wks version or earlier, xl should open it and let you save it as an xl file. if the lotus file is a 123 version or higher, you can open the file in lotus and save it as an xl file. if you don't have lotus, find someone who does. "Ineluctable" wrote: > I am trying to convert several complex Lotus 123 workbooks with formulas into > Excel 2003. How do I do this and maintai...

obtaining data in text form from a table
Hi all, I like to be able to obtain the dates in a text format from the table below. ie Test2 8-Feb Test5 4-Feb,8-Feb Test6 4-Feb,5-Feb, 9-Feb Do I need to do this by macros and if so, any help would be appreciated. Table Care Recipient Surname 4-Feb 5-Feb 8-Feb 9-Feb Test1 Test2 8-Feb Test3 Test4 Test5 4-Feb 8-Feb Test6 4-Feb 5-Feb 9-Feb Vlookup should do what you want, as in: =vlookup(a2,Table,2,false) Adjust the ranges t...

Determine number of rows with data
Hi I am using the macro below to pull some data from an external workbook. The 2 issues I need to sort are: 1. The number of rows in the external workbook can vary. How do I amend this code to pull all of the rows with data? 2. The number of rows in the autofill also may vary. How do I autofill only the number of rows required? i.e the number of rows in column A that contain data. 'Lookup Previous Month Sales Columns("K:K").Select Selection.NumberFormat = "General" Range("K4").Select Selection.FormulaArray = _ "=S...

Delete contents deletes all data and formulas
When I hit delete contents all data and formulas are deleted. How can I delete data without deleting formulas? Hi, You could try this tap F5 - Special - Constants - OK and if that selects the data you want to delete then tap the delete key -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "tdhcrr" wrote: > When I hit delete contents all data and formulas are deleted. How can I > delete data without deleting formulas? First use Find...

COUNTIFS with OR
Hi I have a sheet as below which is around 1000 rows long. Column A contains upto 100 different site codes. Column B always has 2 letters and there are 40 different combinations of the 2 letters possible. I am trying the following (which does not work obviously): COUNTIFS(A:A,1223,B:B,("Red" OR "Blue" OR etc etc)) A B 1 1223 Red 2 1223 Blue 3 1234 Blue 4 1223 Green 5 1235 Orange I know I could use COUNTIF+COUNTIF+.... multiple times but I would need 20 added together and want to simplify the formula. I am now losing the will to live looking for a...

Missing mail after VPN Outlook setup
Hi. Last week we setup VPN to be able to read mail from home (no OWA). After installing Outlook at home and connecting to the exchange server, and syncronizing the data I got all mail/contacts etc on my home computers Outlook. BUT, when I got to work the day after, my Outlook on the work computer was empty, no mails or nothing. Looking in the Exchange server at the mailaccount I can se that it contains over 1000 emails so they seem to still exist on the server. What could this be? Is there som configuration needed? Did you configure the home computer to deliver mail to a personal folde...

Add data to cell w/o loosing initial data
I would like to know if there is a way to add data to data without retyping. For example I have a colum of 18015555555 and I want to add [rfax:(cell #)@/fn=(phone number)] So I would like to add the brackets - copy from a cell - @/fn= and not loose the data already in the spread sheet. Example 2. Add [rfax:company name@fn/=(saved data here) then close bracket. So I want to add data to cells without loosing the data already in the cells. I have about 600 of them to do and I really don't want to do each one by hand. Please let me know if anyone knows how to accomplish this. Tha...

Removing filters from data
Hi. I have recorded a macro to remove filters from data lasts in advance of performing other actions. However if the data is unfiltered the macro falls over with the message Run time error '1004' ShowAllData method of Worksheet class failed. I think I need some sort of if error continue code or something to check filtering first. I would be grateful if someone could point me in the right direction please. Hi Philip Try If Activesheet.Filtermode Then ActiveSheet.ShowAllData -- Jacob "Philip J Smith" wrote: > Hi. > > I have re...

Moving certain data to different sheet
I need to move data that meets a certain criteria, to another sheet within a workbook. For instance, if a column of data is for a certain ZIP code area, I need it to automatically copy to a sheet for that city. Say, 40202 would go to the Louisville, KY sheet. Because Louisville has multiple ZIPs, I would need only the data that begins with 402 to go to that sheet. Lexington KY's data, which begins with ZIP code 405, would go to its own sheet. Macro? Formula? Thanks! This can definitely not be created with a formula. I suggest that you make use of the macros. Rgrds, Kris...

Looking up and matching data
I have two sets of data with the same information but not in the same order and am trying to match the data. In each data set I have 10 pools containing 100 loans. Each pool has a unique ID and each loan within the applicable pool has an ID of 1 to 100. I need to look up the Pool ID, then look up the loan ID so that I can extract the property type information from a third column. The Pool ID and property type is text but the loan ID is a number. I am struggling to put together the right combination of formulas to give the property type for each loan within each pool. Any suggestion...

invisible listbox data
I have developed software in Acces XP that is distributed to two different locations and I have noticed some odd behaviour at one of the locations. Sometimes the data in listboxes or combo boxes is invisible. The data IS PRESENT because you can select and use the records as before (although you can't see which ones you're selecting). The combo boxes are poplulated and have the correct dropdown length for the records one would expect. The listboxes have scroll bars where one would expect a scrollbar and multiselcetion is possible where apropriate. I have played around with th...

create a letter with the data fron work sheet
i have a data sheet for the order.like people order staff lik tea,coffee...etc,i ve data including date,name,department,.....etc. when i put the data i want a letter format which picks up the data fro the sheet then i can send it to the person who made the order as confirmatino letter. like it the letter starts dear "......"(it could pick the name fro c1) also how can i create this letter? does it have to be in excel ?? help pleaseeeeeeeeeeeeeeeeeeee!!!!!!!!!!:( :( :( : -- Message posted from http://www.ExcelForum.com As answered in microsoft.public.excel and microsoft.public....

excel 2007
I have data that looks something like this account#, invoice amount 1, 50 1, 70 1, 80 2, 10 2, 50 2, 52 2, 50 3, 10 4, 30 I need a way to combine all the invoice totals for each account so I have results like this 1, 200 2, 162 3, 10 4, 30 Any suggestions on how to go about doing this? I thought I had done something similar to this with filters before in Excel 2003, but I can't figure out how I did it. Thanks! You can use subtotal or a pivot table in the pivot put the account numbers in the row field and the invoice amount in the data, in subtotal use at each change in account numb...

Copying of non-consecutive, columnar data into consecutive-columnar cells
Hi: I have data located at a1:a9, then a:10 is blank; then, I have 9 more lines of data from a11:a19, and a20 is blank... a1, a11, a21...are all the texts/numbers that I want printed on a different page. But here's the catch: I'd like to print it at locations a1, a2, a3... Specifically, the data that I have appears like this on THIS IS ON SHEET 1: A1: prefix: Mr A2: emailAddress: john.smith@1.com A3: firstName: John A4: lastName: Smith A5: company: ABC Company A6: A7: prefix: Mrs A8: emailAddress: kim.davids@2.com A9: firstName: Kim A10: lastName: Davids A11: company: X...

Export Data from MS-CRM
Is there a way to export all of the data from MS-CRM? Thats a rather general question,......you mean export to another CRM system or just export into another medium? For the most part, most areas have that little excel icon so that you can export into excel...... or you can go into the SQL server and use the export wizard, although I don't think its going to be what you want,....for the most part it will be raw data and you'll have to recreate the relationships and primary fields to see how the objects relate.......... -Gary "John O'Keefe" <jokeefe@finepoint.com...

repaired ext hd
I recently had an external hard drive fail. Sometimes it showed up under my computer and other times not. Did not show up in disk management. Tried on another pc - nogo. So.... I sent drive off for data recovery and received email from comp that said: A. Media evaluation results overview * The file system was structurally damaged preventing access to the data. The file system has been repaired to point to the file data. Can anyone tell me what that means? Is there a way i could "repoint" to data? Thanks. patti On May 5, 7:20=A0pm, patti <pa...@discussions.m...

What are the different methods of representing numerical data?
Can someone answer my questions "What are the different methods of representing numerical data"? "Excel Problem" wrote: > Can someone answer my questions "What are the > different methods of representing numerical data"? Sounds like a test question. What's the context? Is it asking about numerical formats? Or is it asking about date v. time v. other numerical data? (Which really is not "different methods" per se. All are floating-point aka real numbers. But the test might be asking for the specifics of date and time rep...

SumIf Criteria Matches
I am trying to sum the amounts in column c if they match the criteria i colum f. I can sum c if column f is a single criteria. My problem is I wan column c to sum if the criteria in column f is <>. Example: column c column f 1000 -- 13.5 2000 -- 8 3000 -- 15 4000 -- 20 I want to get the sum in column c if column f is >8 and <14.99. Thi should total 1000. I can't seem to find the right formula. I hav tried using =sumif(F2:f19,>8<14.99,C2:c19)....

Check if data has already been formatted.
Hello, I have a sub() as part of a larger set of macros. This particular sub() will take the raw data pulled from an in-house reporting system and format it to suit our needs (adding a couple of columns with formulas to facilitate pivot table creation). This is the code as I have it so far: Sub FormatData() Application.ScreenUpdating = False ActiveWindow.DisplayGridlines = False ' Declarations Dim DataWks As Worksheet Dim LastRow As Long Dim LastCol As Long ' Set the DataWks variable Set DataWks = Worksheets("Data") ...