Excel sum values if exists in another column without vlookup - excel-formula

This is my data
A B C
a a 100
b r 200
c m 300
d b 400
e d 500
I want to sum C if B exists in A.
vlookup won't work because I cannot add a column (for reasons that cannot be changed). This must all be done from one cell. I cannot drag down a formula on any column.
I was thinking something like sumifs(C:C,A:A,{if value for A exists in B:B}
I'm not too familiar with arrays in Excel, but there must be a way to specify
if value for A exists in B:B
Thanks!

Here is an easy way. In D1 enter:
=IF(ISNA(MATCH(B1,A:A,0)),0,1)
and copy down. (column D marks the rows to add)
Then in another cell:
=SUMPRODUCT(C:C*D:D)
or
=SUMIFS(C:C,D:D,1)

A single formula using SUMPRODUCT:
=SUMPRODUCT(--ISNUMBER(MATCH(B1:B5,A:A,0)),C1:C5)
with SUMPRODUCT one should limit the size of the referenced data to that of the actual data to limit the unneeded iterations.

Related

How to search for one value in a column against all values in multiple columns in Excel

I tried a lot to find a solution for the below issue, lets say I have column A,C,D ; I want to take the fist value in column A and check if it exist in C or D entire columns; if exist then I will return A, then take the second value in A and search in C & D columns and so on.
The bottom line, is that I want to find the count of each value in column A that existed in C or D
Thanks
=COUNTIF(C:C,A1:A4)+COUNTIF(D:D,A1:A4)
Using SUMPRODUCT Function
Formula used in cell B2
=SUMPRODUCT((A2=$C$2:$C$7)+(A2=$D$2:$D$7))
And Fill Down!

How to find non matching records from two columns while accounting for duplicate values in Excel

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

excel reference the first column of table

Dog Cat Bird Gary
A 0 C 100%
B 0 B
C ok D 100%
D ok 100%
E no A
F ok F 100%
Is it possible to reference the 1st 2nd or 3rd column by column number/position instead of column header? So instead of
Table1[#Dog]
It would look more like this.
Table1[#(1st column)]
In VBA it is.
ListObjects("Table1").ListColumns(1)
But I need to know if there is a formula way to do this?
Also Just to make clear I DO NOT want to know what column number or letter it is in the worksheet. I want to reference the 1st column by position within the table, NOT header name. TY
If you want to refer to cells in the same row as your formula, which is what it looks like from your question, you can use INDEX.
Above, the formula =INDEX(Table2[#],2) refers to the second column in the same row as your formula.
If you don't want to refer to the row the formula is in, just refer to the whole table and INDEX on the row and column. For example, this refers to the fourth row in the second column:
=INDEX(Table2,4,2)
Note that Table2 refers to the data area of the table - not the headers - just like a database table.
Offset formula.
If Dog is in A1 and you want BIRD in C1 then you would use this formula
=Offset(A1,0,2,1,1)
=Offset(Refecence Cell, X, Y, B, D)
Offset starts a range, down X rows and over Y columns from the reference cell (first tow numbers) and returns a range the size of the second two numbers of B rows and D columns.
Here is a link to a description of the OFFSET function

Get minimum value after HLOOKUP

I have a lookup table like so:
a b c d
1 2 3 4
and a row filled with values a, b, c or d, for example:
d b b d c
I would like to get the minimum value after doing the lookup with the table in a single formula. Something like MIN(HLOOKUP(...)). In the example above, the result would be 2.
I know that I could create a new row with the HLOOKUP and later do a MIN on this row. But in my real case, I have several rows and several lookup tables and I would like to avoid having many intermediate rows.
Do you have any idea?
If your lookup array is named LetterValues and your data is in A1:E1 please try:
=HLOOKUP(CHAR(MIN(CODE(A1:E1))),LetterValues,2,0)
entered with Ctrl+Shift+Enter.
If you're data starts in cell A1, you can use the following array formula.
=MIN(IF(A1:E1="b",A2:E2,""))
It basically looks at the range A1:E1 and checks if it equals b. If it does, the formula stores the value from the row below, if not, it stores nothing.
Now that you have an array of all of the numbers associated with b, the MIN functions returns the smallest.
After typing in the formula, use Ctrl+Shift+Enter and curly brackets will appear around the formula.

If "x" is in column A and "y" is in column B, I want column C to be 5. I have a list of about 190 values. What is the most efficient way to do this?

I have a list of 190 column c values that correspond to specific column a and column b values. I created a huge if statement, but excel says it's too large and I keep messing up parentheses. What is a more efficient way to solve this problem? For example, if column A is "United" and column B is "Brain", I want column C to be 150. All for the first value. Thank you.
If your data is in column A and B. Use concatenate in column C:
Concatenate(A1, B1)
Then in your sheet with the values, insert a column between the values column and the two criteria columns. Use concatenate in that column as well (sane formula as above).
Then on the first sheet in column D use the formula:
vlookup(C1, Sheet2!C1:D190, 2, false)
This is assuming your second sheet is sheet 2 yadda yadda.
Let me know if you run into an issue!

Resources