Excel function for SELECT DISTINCT.. WHERE - excel

I am trying to filter data in an Excel sheet using functions based on multiple columns. For example, if column B has '*ABC*', I want to count the number of unique values in column A.
A B
--- ---
1 xyz
1 abc
2 ABCD
3 AB
4 ABCE
4 qwe
4 ABC
5 xyzABC
For the above example, I am expecting the answer 3, since the number of unique values in A matching '*ABC*' are 2,4 and 5 => 3 unique values.
Index Match only returns the first result and I am not able to figure out how to use Countifs to join both these conditions - unique and wildcard match.

As an Array Formula:
=SUM(IF(ISNUMBER(SEARCH("ABC",B1:B8)),1/COUNTIFS(A1:A8,A1:A8,B1:B8,"*ABC*")))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

Related

Identify if list contains not unique values without countif in a helper column

A B C
1 Product A 1 Error
2 Product B 1
3 Product C 2
4 Product C 2
5 Product D 1
6 Product E 1
7
8
In the table above I want to identify if the values in Column A are unique.
If there is at least one value which is not unique Error should be displayed in Cell C1.
In order to achieve this I went with helper Column B and with the following formulas:
Column B `=COUNTIF($A$1:$A$6,A2)`
Cell C1 =`IF(COUNTA($A$1:$A$6)<SUM($B$1:$B$6),"Error","OK")`
All this works fine.
Now, I am wondering if there is also way to avoid the helper column.
Basically, a formula that goes through Column A and if it identfies at least one not-unique value it should display Error in Cell C1.
use:
=IF(MAX(COUNTIF($A$1:$A$6,$A$1:$A$6))>1,"Error","OK")
This is an array formula and depending on one's version will require the confirmation of Ctrl-Shift-Enter instead of Enter when exiting edit mode.
If one has the dynamic formula UNIQUE() then:
=IF(COUNTA(UNIQUE($A$1:$A$6))<>COUNTA($A$1:$A$6),"Error","OK")
As a normal formula.
Another formula, that will work in Conditional formatting:
=SUMPRODUCT(--(MATCH($A$1:$A$6,A:A,0)<>ROW($A$1:$A$6)))>0

Excel MATCH to sum of two cell values

I have a table of data that include a name column and two numeric columns. Example:
A B C
Fred 4 2
Sam 3 6
George 1 7
I'm wanting to retrieve the name in column A for the largest sum of columns B and C. In the example above, I would want "Sam" because 3+6 is greater than any of the other sums.
I know I could create a hidden column (D) that's filed with
=SUM(B2,C2)
and do something like this:
=INDEX(A:A,MATCH(MAX(D:D),D:D,0))
but I'd rather avoid the hidden column, if possible. Is there a way to perform an index-match based on the sum of two cells?
Use the array formula:
=INDEX(A:A,MATCH(MAX((B:B)+(C:C)),(B:B)+(C:C),0))
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
(Note the appearance of braces in the formula bar)

Excel - Match Value and Get Value of Other Column

I am trying to match 2 values on a table and if match, display the value from other column. Example is as below,
A B C D E F
ABC 1 WWE 5 output (1 FROM ABC) output (10 FROM ABC)
GHI 2 XYY 1
XXY 3 ABC 10
May I know how to do it? Can it be done in Excel
Use an INDEX/MATCH formula, for example in column E:
=INDEX(B:B,MATCH($A1,A:A,0))
And in column F:
=INDEX(D:D,MATCH($A1,C:C,0))
I'd usually wrap these in an IFERROR(,"") function to tidy up any errors. These formulas are based on you searching for the value in column A each time, if you want to search for a string instead simply replace $A1 with "ABC".

Sumproduct matching values in excel

I have two excel tables:
A B C D E
1 John 10 Mark 2
2 Tommy 20 Tommy 3
3 Jane 15 John 4
4 Kate 2
5 Jane 1
Is there a function to sumproduct values in colum B with those values in column E which match by name, i.e. 10*4 + 20*3 + 15*1 ?
You can use sumif for this and just sum up the results when you are done:
=B1 * sumif(D:D, A1, E:E)
Copy that down your sheet, and then add up the totals.
If you don't want a ton of formulas hanging out on your sheet, you could convert this to a CSE/Array formula:
=SUM($B$1:$B$3*SUMIF(D:D, $A$1:$A$3,E:E ))
Just enter that in and hit Ctrl+Shift+Enter to enter it. It will get curly braces around it, which means it's an Array formula.
Since you asked about sumproduct, we could use SUMPRODUCT
=SUMPRODUCT(($A$1:$A$5=A1)*$B$1:$B$5)*SUMPRODUCT(($D$1:$D$5=A1)*$E$1:$E$5)
Now that is assuming there are no repeats (all names are unique). In the event that names are not unique you will have those numbers added together then multiplied.
After you apply that to a column and copied down appropriately, lets say F1 to F3, in F5 you could get your final answer using:
=SUM(F1:F3)

EXCEL match 2 columns against each other

I have two columns of data, they look something like this:
A B C D
1 2 SOME RECORD
2 6 SOME RECORD
3 10 SOME RECORD
4
5
6
7
8
9
10
So basically column A is a list of indices, where some of them appear in column C with corresponding records saved in column D. Column B is currently empty, and what I want to do is if say index 2 appears in both column A and column C (they matches), then put the record beside C2 in the cell B2. So essentially I want it to look like this:
A B C D
1 2 SOME RECORD
2 SOME RECORD 6 SOME RECORD
3 10 SOME RECORD
4
5
6 SOME RECORD
7
8
9
10 SOME RECORD
Can someone help please?!! Thanks!!!
UPDATE: I tried this and it doesn't work. The data in column D is calculated using a UDF and is refreshing every 1 second. The VLOOKUP function fails even though I can see the 2 indices are the same!! Is it because of the format of the cell or column? I.e. does vlookup compare data type as well?
Assuming your data in A starts from A1 - put in B1 the following and autofill:
=IFERROR(VLOOKUP($A1,$C:$D,2,0),"")
This includes handling of missing values.
You'll want this:
B1=VLOOKUP(A1, C:D, 2, FALSE)
This will look up the value in column A within the array spanning columns C and D. It will give you the value found in the second column (D). FALSE makes it an exact match, otherwise you might get 2 and 20 matching because hey, they're kind of similar...

Resources