say I have the following table
1 apple
2 banana
2 apple
3 banana
With COUNTIF(B1:B4;"banana") I would get 2, but I'm searching for a formular that respects the mulitplier to get 5 as result. Is this possible?
Use sum if:
=SUMIF(B1:B4;"banana";A1:A4)
First range to search
Seccond the search item
Third The range for the sum
Related
I have two spreadsheets with names and times. One is specific session times and on the second sheet, I want to sum up the total times based on each instance from sheet one.
Sheet 1: Session Time
Name | Time
David 5
Mike 2
Daniel 3
David 2
Daniel 8
Sheet 2: Total Time (The one for which I need a forumula)
Name | Total Time
David 7
Mike 2
Daniel 11
I tried a countif and vlookup but I couldn't get it match more than one instance of the name on sheet 1. I also tried this suggested formual from a suggested post but its not summing a second instance of the user name
=ARRAYFORMULA(SUM(ifna(VLOOKUP(A2, 'Sheet 1'!A3:AA16, 5, false))))
A2 = David (On Sheet 2)
Sheet 1'!A3:AA16 = List of names in columns A and all the way to AA is a series of columns with numerical values
5 = the column number from with I want to return the sum for every instance of David (2 in this example with a total of 7)
False = its not sorted
Any help is mucho appriciado!
You can use this formula in your Sheet2!B1:
={"Total Time";arrayformula(if(A2:A<>"",sumif(Sheet1!A1:A,A2:A,Sheet1!B1:B),""))}
Or simply use =arrayformula(if(A2:A<>"",sumif(Sheet1!A1:A,A2:A,Sheet1!B1:B),"")) in Sheet2!B2
Get the sum of the range based on a specific criteria using SUMIF()
Basically, get the sum of Sheet1!B1:B if Sheet1!A1:A matches the current cell being checked in arrayformula A2:A
Output:
This can be accomplished with a simple QUERY, e.g.,
=QUERY('Session Time'!A:B, "Select A, SUM(B) WHERE A Is Not Null GROUP BY A LABEL SUM(B) 'Total Time'")
A B C
1 4 Apple
2 5 Orange
3 6 Apple
1 4 Orange
2 4 Apple
3 4 Banana
I want to count each type of column C(if possible also plot it), ie output should be
Apple 3
Orange 2
Banana 1
Just more to a new columns and paste the folloing in its header:
=query(H2:H,"select H, count(H) where H != '' group by H order by count(H) desc label H 'Fruit'", 0)
It is show something like your expection in new two columns beside the original data
As an alternative to the solution already provided, you can make use of UNIQUE and COUNTIF.
Use UNIQUE in order to extract the names for each fruit from the C column
=UNIQUE(C1:C)
Use COUNTIF within an ARRAYFORMULA in order to count the number of times each fruit is present in the C column and later drag it down the E column:
=ARRAYFORMULA(COUNTIF(C1:C,D1))
Reference
UNIQUE Function;
COUNTIF Function.
I have a spreadsheet that works properly in Excel. However, when I import it to Google Sheets it gives me the #DIV/)! error. I am at a loss for how to fix this.
I am trying to rank the items based on the number in column P. I would like for the highest number in column P to be ranked 1, then 2, 3, etc. If two numbers in column P are the same I would like for them to both be ranked the same. However, I don't want the formula to then skip the next number in the ranking order. Also, I am not sure if it matters, but column P displays a number but is technically filled with a formula to obtain that number. Example:
Points column is populated using the following formula:
=SUM(H2,J2,L2,N2,O2)
Points Rank
5 3
3 4
8 1
3 4
6 2
2 5
=SUMPRODUCT((P2 < P$2:P$36)/COUNTIF(P$2:P$36,P$2:P$36))+1
Any ideas?
Add the opposite of the numerator to the denominator to ensure you never receive #DIV/0!.
=SUMPRODUCT((P2 < P$2:P$36)/(COUNTIF(P$2:P$36,P$2:P$36)+(P2 >= P$2:P$36)))+1
When (P2 < P$2:P$36) is false, the numerator will be zero so it doesn't matter what the denominator is as long as it isn't zero.
how to find a sum of 3 higher values from the range of 6 which are on the one row e.g We have integer values A1:A6 like 2 5 7 4 9 9 It should sum 9+9+7 so 25
Is it possible by any formula or something?
Take a look at the answer Extracting the top five maximum unique values
That should provide you with a basic mechanism (QUERY), to get the top 3 values. Then, apply the SUM function to that result.
So, in your case, you would want:
=SUM(QUERY(A2:A6,"select A order by A desc limit 3",-1))
Here's another one:
=SUM(ARRAY_CONSTRAIN( SORT(A1:A6,1,0),3,1))
Shorter version:
=large(A:A,1)+large(A:A,2)+large(A:A,3)
to apply to an entire column, though A:A could be limited to A1:A6.
What I have:
Table 1:
Name / 1 / 2
Peter / Agree / Disagree
So Row 1 will be Name followed by the number 1 - 80. Row 2 will be the name followed by either "Agree" or "Disagree" depending on an answer the user gives on a form.
Example:
Table 2:
Title1 / Title2 / Title3 / Title4
1 / 2 / 3 / 4
5 / 6 / 7 / 8
So Row one is a title row and each title has a column of numbers.
Example:
What I want:
I want to be able to count the number of times a person has put the word "Agree" in table 1 but only for the numbers that appear in each title column in table 2.
Example: If a person put the word "Agree" in table 1 under the numbers 1,3 and 5, then the total for Title1 in table 2 would be 2 where Title2 would be 0, Title3 would be 1, and Title4 would be 0.
Example:
You can see that the last row of each column is how many of the numbers in the Column have the word "Agree" in the other table under the same number.
What I have tried:
So far I am trying to get this working with a COUNTIFS formula. The issue here lies with the fact that I am trying to use a range as BOTH the Criteria Range and the Criteria.
SO, to get around this, I followed the advise given in This Question and came up with the following:
=sum(arrayformula(COUNTIF('Form responses 1'!C1:CD1,C2:C21)))
This works but obviously doesn't take in to consideration the second part of the criteria. My obvious next thought was to try the following:
=SUMPRODUCT(COUNTIFS('Form responses 1'!C1:CD1,C2:C21,'Form responses 1'!C2:CD2,"Agree"))
The issue here is that for some reason is always returns 0 as it doesn't seem to be reading the second criteria.
Question:
Is there a way to have a COUNTIFS formula where both the criteria range and the criteria of the 1 check can be ranges and the the second check can be a standard criteria range and a word as the criteria.
You may consider using countif on array of response lookup like this
=COUNTIF(ArrayFormula(HLOOKUP(C2:C21,'Form responses 1'!$C$1:$CD$2,2)),"Agree")
Change ranges as needed to drag formula down.
Sheet