I have to compare column having same values but not in the same order.
I want to pick the first value in the first column and then find it in the second column.
If I find it then I want to copy it in the third column with the number of records.
I want to repeat this exercise for every value in the first column.
What you're looking for is called VLOOKUP() and is a built-in function of Excel that will do it exactly for you. You can read more about VLOOKUP() here. Examples have also been provided.
Let's suppose that the first column is A and the second column is D (based on your picture) and you want the number of records displayed on column E. In this case you should set the following formulas on E1, E2,... cells:
E1 ----> =COUNTIF(D:D, A1)
E2 ----> =COUNTIF(D:D, A2)...
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
So, I would like to return the contents of all rows where the value in column A is, let's say, 1.
My thought process is that I could use:
=INDEX(row_range,MATCH(1,A:A,0),0))
But Match will only return one value here, i.e. the number of the first row which contains a 1 in column A.
Is there a way of creating an array with the Match formula (thus returning the multiple row numbers, all of which contain '1' in column A) and then place that in the Index array so that it then runs through each of the Match-array values and creates a big long list of values in one array which I can then list out on a separate sheet?
Hope this makes sense...
Here is a demonstration of what I'm hoping for, if that helps! The idea would be that the array as shown would be created, which could then be extended down the column as per the part underneath.
https://i.stack.imgur.com/nCusM.png
Use the file you showed in your example (as "Sheet1") and put these formulas into indicated cells in Sheet2:
Into cell A2 put
=AGGREGATE(15;6;ROW(Sheet1!A:A)/((Sheet1!A:A=1)*1);ROW(A1))
this will give you all the rownumbers where value in A column of sheet1 equals 1.
Into cell B2 put
=COUNTA(INDIRECT("Sheet1!"&A2&":"&A2))-1
this will give you how many cells are filled in that row.
Into cell C2 put
=TEXTJOIN(",";TRUE;OFFSET(Sheet1!$A$1;A2-1;1;1;B2))
This will give you all the cells with data from that row concatenated. If you dont have this formula (first time in 2016 I believe) you can use OFFSET function to list the values in separate columns and then CONCATENATE them.
Copy these three down as many times as you want and into cell C1 put
=TEXTJOIN(",";TRUE;OFFSET(C2;0;0;COUNTIF(Sheet1!A:A;1);1))
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 am trying to come up with a formula that possibly uses the sumproduct function combined with another function.
Let me start by explaining what I have and what I want. If I have a list of 3 product numbers or more in a column, I would like excel to find the product numbers in 2 different possible columns and if they are listed there, I would like excel to multiply and sum.
I am currently using this formula:
=SUM(SUMPRODUCT(($B$27:$B$46='Lists for Estimates'!K2)*($E$27:$E$46*$A$27:$A$46))
+SUM(SUMPRODUCT(($F$27:$F$46='Lists for Estimates'!K2)*($I$27:$I$46*$A$27:$A$46)))
+SUM(SUMPRODUCT(($B$27:$B$46='Lists for Estimates'!K3)*($E$27:$E$46*$A$27:$A$46))
+SUM(SUMPRODUCT(($F$27:$F$46='Lists for Estimates'!K3)*($I$27:$I$46*$A$27:$A$46)))))
The issue with this is I have to continue to add to the formula if I add more to "Lists for Estimates." I would like to change the formula from 'List for Estimates'!K3 and K2 to search the entire column.
Thank you in advance!
Create a new column on your data sheet that multiplies the A and E columns together (so the formula doesn't have to do it), and then use this formula:
=SUMPRODUCT(SUMIF($B$27:$B$46,'Lists for Estimates'!$K$2:$K$3,$F$27:$F$46))
Where column F contains the multiplied values. Adjust column F to suit your actual data. The multiplied value column can be hidden if preferred, or even put on a different worksheet.
My question is how can I find an intersecting cell of a specific column and row number?
My situation is this: with some calculations I find two cells, lets say B6 and E1. I know that I need a row of the first one and a column of the second one. So I could just use ROW and COLUMN functions to get the numbers. After that, I need to find an intersecting cell. Which would be E6 in this example.
I would just use INDEX(A1:Z100;ROW;COLUMN) but I don't know the exact area that I'm going to need - it depends on other stuff. I could use something like A1:XFG65000 but that is way too lame. I could also use a combination of INDIRECT(ADDRESS()) but I'm pulling data from a closed workbook so INDIRECT will not work.
If this would help to know what is this all for - here's a concrete example:
I need to find limits of a section of a sheet that I would work with. I know that it starts from the column B and goes all the way down to the last non-empty cell in this column. This range ends with a last column that has any value in first row. So to define it - I need to find the intersection of this last column and the last row with values in B column.
I use this array formula to find the last column:
INDEX(1:1;MAX((1:1<>"")*(COLUMN(1:1))))
And this array formula to find the last row:
INDEX(B:B;MAX((B:B<>"")*(ROW(B:B)))
Last column results in E1 and last row results in B6. Now I need to define my range as B1:E6, how can I get E6 out of this all to put into the resulting formula? I've been thinking for a while now and not being and Excel expert - I couldn't come up with anything. So any help would really be appreciated. Thanks!
You can use an Index/Match combination and use the Match to find the relevant cell. Use one Match() for the row and one Match() for the column.
The index/match function to find the last cell in a sheet where
column B is the leftmost table column
row 1 is the topmost table row
data in column B and in row 1 can be a mix of text and numbers
there can be empty cells in column B and row 1
the last populated cell in column B marks the last row of the table
the last populated cell in row 1 marks the last column of the table
With these premises, the following will return correct results, used in a Sum() with A1 as the starting cell and Index to return the lower right cell of the range:
=SUM(A1:INDEX(1:1048576,MAX(IFERROR(MATCH(99^99,B:B,1),0),IFERROR(MATCH("zzzz",B:B,1),0)),MAX(IFERROR(MATCH(99^99,1:1,1),0),IFERROR(MATCH("zzzz",1:1,1),0))))
Since you seem to be on a system with the semicolon as the list delimiter, here is the formula with semicolons:
=SUM(A1:INDEX(1:1048576;MAX(IFERROR(MATCH(99^99;B:B;1);0);IFERROR(MATCH("zzzz";B:B;1);0));MAX(IFERROR(MATCH(99^99;1:1;1);0);IFERROR(MATCH("zzzz";1:1;1);0))))
Offset would seem to be the way to go
=OFFSET($A$1,ROW(CELL1)-1,COLUMN(CELL2)-1)
(The -1 is needed because we already have 1 column and 1 row in A1)
in your example, =OFFSET($A$1,ROW(B6)-1,COLUMN(E1)-1) would give the value in E6
There is also ADDRESSS if you want the location: =ADDRESS(ROW(B6),COLUMN(E1)) gives the answer $E$6
The following webpage has a much easier solution, and it seems to work.
https://trumpexcel.com/intersect-operator-in-excel/
For example, in a cell, type simply: =C:C 6:6. Be sure to include one space between the column designation and the row designation. The result in your cell will be the value of cell C6. Of course, you can use more limited ranges, such as =C2:C13 B5:D5 (as shown on the webpage).
As I was searching for the answer to the same basic question, it astounded me that there is no INTERSECT worksheet function in Excel. There is an INTERSECT feature in VBA (I think), but not a worksheet function.
Anyway, the simple spacing method shown above seems to work, at least in straightforward cases.