Column A has Apples,Oranges, Pears multiple times.
Column B has the count against them (note, some of these may be blank).
I'm looking for a formula to count just Apples and Oranges where their count is neither blank nor 0.
I tried the formula below, but I get the count of Apples only:
=COUNTIFS(A1:A21,{"Apples","Oranges"},B1:B21,">0")
You need to use your formula in a sum function like this:
=SUM(COUNTIFS(A1:A21,{"Apples","Oranges"},B1:B21,">0"))
The reason is, that your function creates an array with the counts of apples and oranges respectively. You have to sum the elements in this array to get your desired result.
Related
I would like to add the rows if the value in each cell is less than 100 and if the columns headings were "Tom", "Dick" and "Harry"
So in Row 1, only Dick is less than 100 so the sum is 7.
In Row 2, Tom and Harry are less than 100 individually so the sum is 79.
I have over 30, 250x250 matrices where I would like to get conditional sums of a seven staggered columns. All the combinations of SUMIFs I have tried seem to be giving errors.
I don't just want to add, I would like to be able to do other things, like just count how many times Tom, Dick, and Harry have individually less than 100 or calculate other statistics like mean, median etc.
I would limit the criteria range to each row and then evaluate. This approach should work for COUNTIFS too (take them individual i.e. not aggregate the counts as we do with the SUM).
The formula for SUM would look like this:
=SUMIFS(B2:F2,$B$1:$F$1,"Tom",B2:F2,"<100")+
SUMIFS(B2:F2,$B$1:$F$1,"Dick",B2:F2,"<100")+
SUMIFS(B2:F2,$B$1:$F$1,"Harry",B2:F2,"<100")
So the formula logic is (this logic should work for Countifs too):
SUMIFS(B2:F2,$B$1:$F$1,"Tom",B2:F2,"<100")
SUMIFS(Return value from row, Search for "Tom", given that the return value is <100), we do the same for the other people too.
EDIT:
For the countif same logic tested:
=COUNTIFS($B$1:$F$1,"Tom",B2:F2,"<100")
The program has 5 columns.
Column A has item names
Column B has item sizes
Column C has item quantities
Column D has items that i need
Column E has the sizes for those items in the rows corresponding to the items
Most items do not have multiple sizes, but for the ones that do, there will be multiple entries of that item in column A.
What I need to do is take all the items from column D and find them in column A and give me the corresponding quantity from C.
I have been using this code to achieve this. =INDEX(C:C,MATCH(D:D,A:A,0))
This works for all items besides the ones with multiple sizes. For these items it just spits back the first size number every time.
Would there be a way to match A and D, and then check if there is a value in the size column, if so, give out the correct number?
I see how my wording is confusing here is an example of what I mean.
apples 5lb bag 12 apples 10lb bag
apples 10lb bag 13
bananas 5 grapes
grapes 7
Which using the is line of code "=INDEX(C:C,MATCH(D:D,A:A,0)) " would result in giving me the correct "7" for the grapes, but for the apples, it would give me the first result it comes across, which is the 12.
How would I get it to check the other columns to give me the 13 for apples?
If I understand correctly then this will get you the correct number:
=IF(E2<>"",SUMIFS(C:C,A:A,D2,B:B,E2),SUMIFS(C:C,A:A,D2))
I have a basic problem in Excel. I have a row with names and one with numbers. I try to find what is the sum of these numbers for a special name.
ex.
A B
Apple 12
Apple 12
Kiwi 9
Apple 4
Banana 51
Kiwi 12
Banana 4
Kiwi
So far I just use a basic sumproduct which works well. Like
=Sumproduct((A1:A8=A1)*(B1:B8)
This formula gives me back my total number of Apples
(12+12+4).
The problem is, if a cell contain some formula, then I have #VALUE! result.
Let say the last cell called Kiwi contain a code like
=if(A64="", "", 12)
Then it makes Kiwi empty if A64 is empty. Great.
But sumproduct don't work anymore.
I can't sort the name... any ideas?
Thank you
You can simply use =SUMIF() formula to get sum of these numbers for a special name.
=SUMIF($A$1:$B$64,A1,$B$1:$B$64)
or
=SUMIF($A$1:$B$64,"kiwi",$B$1:$B$64)
You can change these ranges based on your list. (You can even define dynamic name in Name Manager and then you can use that Name as your range.)
It's not the fact that your cell is calculated (contains a formula), it's because the result of the formula is a text.
Maybe you could use à 0 instead of the 0-length text and apply conditional formatting to your cells (font colour white if 0 value)
=if(A64="", 0, 12)
I have a file with data in the following format:
text value1 value2
Given value 1 and value 2 meet some criteria, find all the unique text values.
The exact data looks like this:
john 10 20
john 15 35
mark 20 10
mark 25 15
tom 25 40
lee 16 50
If val 1 <=25 and value 2 <=35 the number of unique text = 2 (john and mark)
I have to do this using formulas not filters.
I've been trying combinations of frequency, countifs, sumproducts and a whole range of other methods and can't seem to hit what I'm looking for.
Assuming that text, value1, and value2 are in columns A, B, and C respectively ...
In D1, enter the formula =IF(AND(B1<=25,C1<=35),A1,"") and copy it down the column
Use the formula =SUMPRODUCT((D:D<>"")/COUNTIF(D:D,D:D&"")) for your answer
If you want to list the unique values rather than count them, something like this:-
=IFERROR(INDEX(A$2:A$7,MATCH(0,IF((B$2:B$7>25)+(C$2:C$7>35),1,COUNTIF(E$1:E2,A$2:A$7)),0)),"")
entered as an array formula starting in E2 ( and assuming that you are using columns A,B and C for your data.
See this reference for explanation.
The following formula will do what you are asking:
=SUM(IF(FREQUENCY(IF(B2:B7<=25,IF(C2:C7<=35,MATCH(A2:A7,A2:A7,0),""),""),IF(B2:B7<=25,IF(C2:C7<=35,MATCH(A2:A7,A2:A7,0),""),""))>0,1))
This is an array formula so confirm it with Ctrl-Shift-Enter.
I referred to this webpage.
Also found a shorter one:
=SUM(--(FREQUENCY(IF(B2:B7<=25,IF(C2:C7<=35,COUNTIF(A2:A7,"<"&A2:A7),""),""),COUNTIF(A2:A7,"<"&A2:A7))>0))
Found and modified from hre.
Assume I have the following table:
A B C
1 Week 1 Week 2
2 Melissa 114.7 82.8
3 Mike 105.5 122.5
4 Andrew 102.3 87.5
5 Rich 105.3 65.2
The names are in column A, the Week values are in Row 1. (So A1 is blank, B1 = Week 1, and A2 = Melissa.)
I'm trying to build a formula that looks at all the values in a known range (in this example, B2:C5), chooses the highest value of the bunch (here, 122.5) and returns the name of the person from Column A that got that value. If I use this formula, it works for the values in range B2:B5:
=INDEX(A2:A5,MATCH(MAX(B2:B5),B2:B5,0))
That returns Melissa but if I expand the range to include more than just column B's values, I get an #N/A returned:
=INDEX(A2:A5,MATCH(MAX(B2:C5),B2:C5,0))
The weird part (to my simple brain) is that the MATCH portion of the formula works fine, if I just put in this formula, it returns the highest value of 122.5 from C3:
=MAX(B2:C5,B2:C5,0)
So clearly something it going wrong when I'm using either the MATCH or INDEX commands.
Hopefully this makes sense and someone can point out my error?
Try this:
=INDEX(A:A,MAX((B2:C5=MAX(B2:C5))*ROW(B2:C5)))
This is an array formula and must be confirmed with Ctrl+Shift+Enter.
Note: Match can only search one vector at a time. It can be one row or one column or one array. It cannot be two or more rows or columns or a 2D array.
Do it "twice"? Please try:
=INDEX(A2:A5,IFERROR(MATCH(MAX(B2:C5),B2:B5,0),MATCH(MAX(B2:C5),C2:C5,0)))
If you are going to have up to 52/53 weeks to cope with I'd suggest instead inserting a helper column with the MAX for each row. Make that an new (inserted) ColumnA (say =MAX(C2:BC2) etc.) and a simple VLOOKUP should serve, say:
=VLOOKUP(MAX(A:A),A:B,2,0)