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.
Related
I have two large columns.
Column A contains 100,000 different numbers/rows. Column B contains 100,210 numbers/rows. They have the same numbers except column B has 210 extra rows. I need to be able get the values of that extra 210 rows.
The issue im having is that the numbers in these rows are not unique.
For example,
Column A contains the following numbers: 2,1,3,4,5,5,6,7
Column B contains the following numbers: 1,2,3,4,5,5,5,5,6,6,7,8
I want the outcome result to be: 5,5,6,8
I can't seem to wrap my head around a way to do this.
I have the two columns in a text file that im importing into excel. If there are better ways to do it outside of excel, I am open to it too.
With the Dynamic Array formula Filter:
=FILTER(B1:B12,COUNTIF(OFFSET(B1,0,,SEQUENCE(ROWS(B1:B12))),B1:B12)>COUNTIF(A:A,B1:B12))
Without FILTER:
Put this in the first cell and copy down:
=IFERROR(INDEX(B:B,AGGREGATE(15,7,ROW(B1:B12)/(COUNTIF(OFFSET(B1,0,,ROW(INDEX($ZZ:$ZZ,1):INDEX($ZZ:$ZZ,ROWS(B1:B12)))),B1:B12)>COUNTIF(A:A,B1:B12)),ROW($ZZ1))),"")
Try to follow these steps, supposing that Column A has less values than the Column B and the rows start at 1:
A. Create Column C.
In the cell C1 place the function: =COUNTIF(A:A;B1)
Copy this function to the rest of cells, for all items of Column B. So, cell C2 will have the function =COUNTIF(A:A;B2) and so on.
B. Create column D.
In the cell D1 place the function: =COUNTIF($B1:$B1;B1)
Copy this function to the rest of cells, for all items of Column B. So, cell D2 will have the function =COUNTIF($B$1:$B2;B2) and so on.
C. Create column E.
In the cell E1 place the function: =IF(D1<=C1,"Exists","Missing")
Copy this function to the rest of cells, for all items of Column B. So, cell E2 will have the function =IF(D2<=C2,"Exists","Missing") and so on.
D. Filter to show only the rows that Column E values are "Missing".
Of course you can combine all above 3 columns to one (e.g. in Column F), so these cells will have the functions:
F1: =IF(COUNTIF($B$1:$B1,B1)<=COUNTIF(A:A,B1),"Exists","Missing")
F2: =IF(COUNTIF($B$1:$B2,B2)<=COUNTIF(A:A,B2),"Exists","Missing")
and so on
Explanation:
In column C we count how many times the value of the respective cell
of Column B exist in the whole Column A.
In Column D we count how many times we have "met" this value in Column B so far.
In Column E we check if we have "met" the value more times that it exists in Column A. If indeed we have "met" it more times, then we mark the cell as "missing"
Tested with the example you provided and works okay.
I hope it helps!
Good luck!
EDIT - Addition of Screenshot
I have two sheets in Excel, Sheet1 and Sheet2.
They both contain 3 columns A, B and C.
My goal is to get values from C in Sheet2 to C in Sheet1, based on conditions comparing the values in both A and B at the same time.
A in Sheet2 contains numbers grouped together, for example 11,11,13,13,12,12. A in Sheeet1 contains some of those numbers, but not nessecarily in the same order or the same number of rows, for example 11,11,12,13,13.
B in Sheet2 also contains numbers like 2,1,1,2,1,2. B in Sheet1 again contains part of those numbers. For example, 1,2,1,1,2.
There are only unique combinations of pairs in A and B (in that specific order) for Sheet1 and Sheet2 respectively.
C in Sheet2 consists of numbers connected to the specific combination of numbers in A and B.
Now, I want to fill C in Sheet1 based on the values from C in Sheet2. For example for C1: Get the value (row x) in 'Sheet2'!Cx, so that 'Sheet1'!A1='Sheet2'!Ax, AND 'Sheet1'!B1='Sheet2'!Bx (which would be the 2nd row in this example).
I was thinking about something like
C1=INDEX('Sheet2'!C:C;...)
where
...=IF(AND(MATCH(A1;'Sheet2'!A:A;0);MATCH(B1;'Sheet2'!B:B;0));?;?)
?= I don't know what I would write here, but I would want the return value of IF be the row number where both conditions are true.
The problem is that MATCH only returns the first number in A and B respectively for which the condition is true, while I have several non-unique numbers in A. I would want to look through the whole 'Sheet2'!A:A and get all the matching values, and then look through the corresponding 'Sheet2'!B:B to check the second condition.
Or there might be a completely different take on this problem. Do someone have a suggestion on how to solve this?
Here is a way to look at multiple values in a MATCH() function, example:
Sheet1:
Sheet2:
Formula in C2 sheet1:
{=IFERROR(INDEX(Sheet2!$C$2:$C$6,MATCH(Sheet1!A2&Sheet1!B2,Sheet2!$A$2:$A$6&Sheet2!$B$2:$B$6,0)),"")}
Note: It's an array formula so enter through CtrlShiftEnter
Result:
C1 Formula =INDEX(Sheet2!C:C;MATCH(A1;Sheet2!A:A;0);MATCH(B1;Sheet2!B:B;0))
I want to define a dynamic range that will expand the rows and columns of my range whenever a new row or column is inserted. My current formula does not want to expand to cell $T$13. My headers start in row $M$7. How can I adjust my formula?
Formula Being Used
=OFFSET(Sheet1!$M$8,0,0,COUNTA(Sheet1!$M:$M),COUNTA(Sheet1!$1:$1))
I need my range to expand to cell $T$13
Right now, your formula counts the number of text values in column M.
That is not a robust approach because column M contains only five text values, but columns S and T have many more values.
If you don't know which column may have the most number of entries, you can introduce a helper cell in each column that counts the number of entries below. I suggest you insert a new row 2. In column M, for example, put a formula in M2
=counta($M$3:M$99999)
Copy that formula across to column T.
Next you can evaluate which of the columns has the largest number
=max(M2:T2)
This can be plugged into your original formula like this:
=OFFSET(Sheet1!$M$8,0,0,max(M2:T2),COUNTA(Sheet1!$1:$1))
So now, instead of just looking at how many rows are in column M, the formula uses the maximum number of rows in the columns M to S.
You can now hide row 2 if it upsets your worksheet design.
Edit: the mere count of text values with CountA will ignore blank cells and will return incorrect results. You really need a formula to find the row number of the last populated cell in each column.
This should really be a new question, but here goes
If the column has number values you can use
=MATCH(99^99,B5:B999,1)
If the column has text values you can use
=MATCH("zzz",C5:C999,1)
Adjust your ranges accordingly.
I ended up using the solution mentioned by #tevlyn.
In range$M2:$T2
I have the follolwing formula =IFERROR(MATCH(99^99,M$8:M$999,1),0).
I've added IFERROR because my data doesn't always have data stretched to $T2.
I then defined my range in name manager using:
=OFFSET(Sheet3!$M$8,0,0,MAX(Sheet3!$M$2:$T$2),COUNTA(Sheet3!$1:$1))
This still works even if there are blanks in between the range.
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.
I have seen questions on here that are similar but not the exact issue I am having. It is below and please forgive me if I don't explain this well.
I have 3 columns.
Column A is a list of file numbers in our system. This column contains many duplicates and is 172522 rows.
Column B is that same list of file numbers, but with the duplicates removed. This is 28858 rows.
Column C is a list of Reference numbers corresponds with Column B exactly, i.e. C2 is a reference number for B2 and so on
I need a query that pulls the reference number from C and places in it column D, for as many times as the file number occurs in Column A. So I get a list of duplicated filenos with their corresponding duplicated Reference numbers
Is this possible?
=VLOOKUP(A1,$B$1:$C$28858,2, False)
Vlookup takes a value and finds it in a "range" and then allows you to take another value in that range and return it. In this case, the 2nd column of range B,C. Though i believe the first column in the range is always the one it has to look through.