I need to sum all values in Column A where Column B is a duplicate.
Above is a sample of the data. Column B has urls and Column A has counts for the urls. What I want is to sum the values in Column A for duplicate values in Column B.
Example:
The output for _.apelabs.net should be 6.
How can I achieve this?
I think you are looking for the function =COUNTIF(Range,Criteria)
Here is a link that shows a usage example.
As #Andresson stated, if you're trying to count the number of times a specific url appears, you might want to use the COUNTIF function: =COUNTIF(range, criteria).
COUNTIF Example:
Using =COUNTIF(B:B, "_.apelabs.net")
would return 3 in your sample data (assuming your image includes the only instances of "_.apelabs.net").
This example of the COUNTIF function is the same as saying, "count the total number of times a cell in Column B (i.e. B:B) equals "_.apelabs.net"."
However, if you're wanting to sum together all the values in Column A where the corresponding url in Column B matches the given criteria, you'll want the SUMIF function: =SUMIF(range, criteria, [sum_range]).
SUMIF Example:
Using =SUMIF(B:B, "_.apelabs.net", A:A)
would return 5 in your sample data (again assuming your image includes the only instances of "_.apelabs.net").
This example of the SUMIF function is the same as saying, "each time a cell in Column B (i.e. B:B) equals "_.apelabs.net", sum together the values in Column A (i.e. A:A) that are located in the same row as each "_.apelabs.net" found in Column B."
Additionally, you can also use a pivot table, as #ScottCraner suggested. It's all a matter in how you want to present your findings.
Related
Looking for help with this task. Here's is a portion of the table I'm working with:
What I'm trying to do is have the cells in Column B (MWD) return the value of the adjacent cells in Column C (Pseudo). Column A (Data Set) has the same values as Colum B but including duplicates. I need a formula where the duplicates in Column A will return the same value that it matches in column B.
Example: I need...
all the duplicate 1010001's to return pseudo 1
all the duplicate 1020001's to return pseudo 2
all the duplicate 1020002's to return pseudo 3
and so on...
I was trying to use index match function but don't know if I'm constructing the formula wrong or if it's the correct formula to use.
If data is sorted by column A, you can use one formula:
=IF(COUNTIF($A$1:A2,A2)>1,C1,C1+1)
if not, then other
=IF(COUNTIF($A$1:A2,A2)>1,INDEX($C$1:C2,MATCH(A2,$A$1:A2,0)),MAX($C$1:C1)+1)
in both cases copy the formula in second row (in C2 cell in my examples). To the first row add 1 manually.
First example:
Second example:
I have an Excel spreadsheet with four columns, call them A, B, C, and Value. What I want to do is sum the Value column but only include those cells that have a certain criteria matching in columns A, B and C.
An example, in English: SUM the values in the Value column that have a value of 6 in column A, a value of 10 in column B and a value less than 15 in column C.
Thanks
Make a table like the attached image in excel.
In B10 put:
=SUMIF(A2:A8,B14,B2:B8)
In the B14 put the criteria.
I was searching for the same thing but the multiple criteria were in a single column. In my case, I was using LibreOffice (which has the same syntax but uses ; instead of , as separators).
The solution is to sum multiple SUMIF
=SUMIF(A2:A8,"porshe",B2:B8)+SUMIF(A2:A8,"porshe",B2:B8)+SUMIF(A2:A8,"mazda",B2:B8)
If you want the OR operator on the sum.
If you want AND operator you need to use SUMIFS that has multiple criteria and ranges.
=SUMIF(B2:B8,"porshe",A2:A8,"electric",C2:C8)
My spreadsheet has a list of names (some are repeated) in column A, a list of numbers stored in a string in column B, and column C uses a formula to get the first number of the string in column B. In column E have created a list of the unique names from column A, in column F a number of times they appear in the data list and in column G i then want to fetch the corresponding number data from column C each time it appears in the list to calculate average numbers.
I have tried this
=SUMPRODUCT(($A$1:INDEX($A:$A,COUNTA($A:$A))=$E4)*($C$2:INDEX($C:$C,COUNTA($C:$C))))/$F4
The problem i have is that in the list of data some of the cells in column C are blank so i am getting a #VALUE error.
Here is a screenshot of what i am trying:
Is there anyway to tell SUMPRODUCT to skip the rows where there is no number data?
Obviously this is just an example and my actual spreadsheet is a little more complicated, there are thousands of rows of data and the names are repeated many times over.
Empty cells are not your problem. It would just be accepted in a formula like yours. Unfortunately the problem is because you have gaps, COUNTA will return a range that's not equal to column A > COUNTA in column A will return 15, whereas COUNTA in column C will return 11. Unequal ranges will return #VALUE
In this specific case your issue is resolved through:
=SUMPRODUCT(($A$1:INDEX($A:$A,COUNTA($A:$A))=$E4)*($C$1:INDEX($C:$C,COUNTA($A:$A))))/$F4
In G4, copied down :
=SUMIF($A:$A,$E4,$C:$C)/$F4
Edit : SUMIF() can use whole column reference of which bounded on used range only, and can avoid to use dynamic range.
Above is a snippet of data that I have (in Sheet1).
My task is to count the number of times "C" is in, let's say from B to C, (the formula will be written in Sheet2 for this). I have the code for that and it works fine.
But what can I do to get the count based on a particular UserID entered in cell A1 of Sheet2.
For ex: if 'Sheet2'!A1=3 then the count in row 3 of form B to C should be given:
(Result = Countif('Sheet1'!"B2:B4","C"))
Hope my explanation was understandable. I need a formula for this not macro.
I tried to get the row ID using Index Match but I am not able to combine it with CountIf.
Both VLOOKUP and INDEX MATCH can be used only if I want one cell value, but not multiple values in same row.
Result = Countif('Sheet1'!"B2:B4","C")
Not the most elegant formula, but the following should achieve your desired result:
=COUNTIFS(Sheet1!A:A,Sheet2!A1,Sheet1!B:B,"C")+COUNTIFS(Sheet1!A:A,Sheet2!A1,Sheet1!C:C,"C")+COUNTIFS(Sheet1!A:A,Sheet2!A1,Sheet1!D:D,"C")+COUNTIFS(Sheet1!A:A,Sheet2!A1,Sheet1!E:E,"C")+COUNTIFS(Sheet1!A:A,Sheet2!A1,Sheet1!F:F,"C")
If you know how to use Names in excel, you can define the following names:
Rng_Data represents all your data in Column B to F
List_User represents all your data in Column A
then use the following formula to find the desired count:
=SUMPRODUCT((Rng_Data="C")*(List_User=Sheet2!A1))
Where Sheet2!A1 is the given User ID in cell A1 on your second sheet. You can drag this formula down to apply to the rest.
In my following screen-shot, I used two sets of data to test the outcome. The first set is the same as yours and the User ID in Column A is unique. In the second set of data, there are duplicated User ID and the formula still finds the occurrence of C for the given User ID as highlighted.
SUMPRODUCT sometimes work like COUNTIFS but in a more powerful way.
You can read this article to learn more about SUMPRODUCT: Excel SUMPRODUCT function with formula examples
Cheers :)
The formula should sum up the column C based on Column A and B when two column value matches and displays the sum value only in the first cell D2 of Column D as shown in figure "60" & "67".
I am trying with SUMIFS but not getting the Output as required.
=SUMIFS(C2:C6;A2:A6;"A:A";B2:B6)
Try this formula in cell D2:
=IF(SUMPRODUCT(--($A$2:$A2&$B$2:$B2=$A2&$B2))=1,SUMPRODUCT(--($A$2:$A$6&$B$2:$B$6=$A2&$B2),$C$2:$C$6),"")
It should give expected output.
It might also be better/more efficient if you create a helper column (which stores concatenation results, instead of doing the concatenation multiple times in each formula).