Excel - list entities (items) - excel

Friends,
I need to list all the unique entities (items) in a Excel spreadsheet, how to?
E.g.
**List1**
1
1
1.1
2
a
a
aa
b
c
c
And I need a certain function that returns:
**Entities**
1
1.1
2
a
aa
b
c
Then I can count the occurence of each entity (using COUNTIF function).

With data in column A, in B2 enter the array formula:
=IFERROR(INDEX($A$2:$A$11,MATCH(0,COUNTIF($B$1:B1,$A$2:$A$11),0)),"")
In C2 enter:
=COUNTIF($A$2:$A$11,B2)
and copy down.
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.

You can also apply pivot to your list to identify uniqueness. One you have identified the unique list, you can apply count if formula.

Related

Matching multiple value in excel using index and match

I used index and match to identify the values of the table and matched it. However I am facing trouble when I try to get b and c, a is matched correctly
A. B C D.
1 a b c
2 fruit1 a
3 fruit0
4 fruit3
5 fruit5 a
E F
1 fruit1 a
2 fruit0 c
3 fruit3 b
4 fruit5 a
My formula is
=Iferror(if(index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)) = b$2,index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)), ""),"")
If your data table is in E1:F4, and you are trying to look up the fruit names that appear in column A starting at A2, and place the correct letter next to them in column B, then there's no need for the IF and the sequences of MATCHes.
All you need is this, pasted into cell B2 and copied down, is this:
=IFERROR(INDEX($F$1:$F$4,(MATCH(A2,$E$1:$E$4,0))),"")
An easier approach to this is just:
=VLOOKUP(A2,$E$1:$F$4,2,FALSE)
or to be safer:
=IFERROR(VLOOKUP(A2,$E$1:$F$4,2,FALSE),"")
And if you have access to O365 Excel and the newer XLOOKUP function, you can use the following examples. XLOOKUP incorporates the "not found" result so you don't have to do a separate IFERROR. Do do it on a cell-by-cell basis as you had before, put this in B2 and copy it down:
=XLOOKUP(A2,$E$1:$E$4,$F$1:$F$4,"",0)
If you want to go one step further, you can apply the XLOOKUP as an array or "spill" formula, you change the lookup_value to be the A1:A4 and it does the rest. Place this in B2 and it will fill B2 through B5:
=XLOOKUP(A2:A5,$E$1:$E$4,$F$1:$F$4,"",0)

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

Formula to Return Text in the Row of Largest Number

Column A Has Text & Columns B, C & D contain numbers.
For Ex.)
A... …B C D
John 4 6 2
Dave 4 6 4
Mike 4 5 1
Bill 2 5 9
I would like a cell to return the name in column A that has the Largest Number in Column B. And if there are similar numbers, go to the next column and determine which is highest, and if that is tied go to the next column and so on.
Any help would be appreciated.
We can de-conflict ties.In E1 enter:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))
and copy down. Then in another cell enter:
=INDEX(A:A,MATCH(MAX(E:E),E:E,0))
EDIT#1
This is only good for 3 columns of numbers, but it is very easy to add additional de-confliction terms if necessary:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))+E1/(1000*MAX(E:E))
For an expandable number of rows/columns, use a helper row with the same number of columns as number columns in your data. The formulas below reference the following image (the data are in A1:G7):
B9-->=MAX(B1:B7)
C9 (fill over the remaining columns to G9)-->
=MAX(IF(MMULT(--($B1:B7=$B9:B9),--(ROW(INDIRECT("1:"&COLUMNS($B9:B9)))>0))=COLUMNS($B9:B9),C1:C7))
The following formula will give the answer (shown in A9 above):
=INDEX(A1:A7,MATCH(TRUE,(MMULT(--($B1:G7=$B9:G9),--(ROW(INDIRECT("1:"&COLUMNS($B9:G9)))>0))=COLUMNS($B9:G9)),0))
UPDATE WITH ALTERNATIVE METHOD
Using a helper column instead, again referencing the image below (the data are in A1:G7):
I1 (fill down to I7)-->
=SUM(--(MMULT(SIGN(B1:G1-$B$1:$G$7)*2^(COLUMN(G1)-COLUMN(A1:F1)),--(ROW(INDIRECT("1:"&COLUMNS(B1:G1)))>0))>0))
The following formula will give the answer (shown in J1 above):
=INDEX(A1:A7,MATCH(MAX(I1:I7),I1:I7,))
As a bonus, notice that the helper column corresponds to the order that you would get from sorting the data by each column left-to-right. In other words, you could use the helper column to perform a formula-based multi-column sort on strictly numeric data. For the last image, entering the following array formula into a range with the same dimensions as A1:G7 gives a descending sort on columns B through G:
=IF(A1:A7=A1:A7,INDEX(A1:G7,MATCH(ROW(A7)-ROW(A1:A7),I1:I7,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 extract unique objects from list

I have a large list of companies who collaborate with my company. My company is broken down into different research groups. A company might collaborate with a single research group multiple times on the list or with multiple research groups.
I would like to find out which companies only collaborate with a single research group. Example of data is below, you can see that company A only collaborates with group 1 but multiple times, but company B collabs with many groups. How can I count this?
Examples data:
Group Company
1 A
1 B
1 C
1 A
1 C
2 D
2 D
2 E
2 E
2 B
2 D
3 D
3 F
3 B
3 F
4 G
4 B
4 B
It would be a binary result, 1=company is unique to group, 0=company is not unique to group.
An extension to this (although not included in my question) would be, how many groups do companies collab with on average
There's a workaround for what you want to achieve. Following solution use couple of helper columns and at the end will give result whether company is unique to group or not and count of groups companies collaborate with.
Assuming your data Group and Company are in Column A and Column B respectively follow the following steps:
Step 1: Get unique combination of Group and Company
In Cell D2 enter the following formula and drag/copy down as required.
=IFERROR(INDEX($A$2:$A$19 & "," & $B$2:$B$19,MATCH(0,INDEX(COUNTIF($D$1:D1,$A$2:$A$19 & "," & $B$2:$B$19),0,0),0)),"")
Step 2: Get count of each combination in data
In Cell E2 enter the following formula and drag/copy down till the row where Column D display values.
=COUNTIFS($A$2:$A$19,LEFT(D2,(FIND(",",D2,1)-1)),$B$2:$B$19,MID(D2,FIND(",",D2)+1,256))
This formula will give the count of occurrence of each combination from Column D in your data. For example, Group 1 and Company A occurs two time in you data, Group 2 and Company D occurs 3 times in your data, and so on.
Step 3: Get list of unique companies from Column B
In Cell F2 enter the following formula and drag/copy down as required.
=IFERROR(INDEX($B$2:$B$14,MATCH(0,INDEX(COUNTIF($F$1:F1,$B$2:$B$14),0,0),0)),"")
Step 4: Get count of groups each company collaborate with
In Cell G2 enter the following formula and drag/copy down till the row where Column F display values.
=COUNT(IF(MID($D$2:$D$12,FIND(",",$D$2:$D$12)+1,256)=F2,$E$2:$E$12))
This is an array formula so commit it by pressing Ctrl+Shift+Enter
Step 5: Check whether company is unique to Group or not
In Cell H2 enter the following formula and drag/copy down till the row where Column G display values.
=IF(COUNT(IF(MID($D$2:$D$12,FIND(",",$D$2:$D$12)+1,256)=F2,$E$2:$E$12))=1,1,0)
Again, this is an array formula so commit it by pressing Ctrl+Shift+Enter
or instead use this formula =IF(G2=1,1,0)
EDIT : As per requirement mentioned in comment
In Cell J2 enter:
=IFERROR(INDEX($B$2:$B$19 & "," & $A$2:$A$19,MATCH(0,INDEX(COUNTIF($D$1:J1,$A$2:$A$19 & "," & $B$2:$B$19),0,0),0)),"")
In Cell K2 enter:
=COUNTIFS($A$2:$A$19,MID(J2,FIND(",",J2)+1,256),$B$2:$B$19,LEFT(J2,(FIND(",",J2,1)-1)))
In Cell L2 enter:
=IFERROR(INDEX($A$2:$A$19,MATCH(0,INDEX(COUNTIF($L$1:L1,$A$2:$A$19),0,0),0)),"")
In Cell M2 enter:
=COUNT(IF(VALUE(MID($J$2:$J$12,FIND(",",$J$2:$J$12)+1,256))=L2,$E$2:$E$12))
This is an array formula.
In Cell N2 enter:
=IF(N2=1,1,0)
or
=IF(COUNT(IF(VALUE(MID($J$2:$J$12,FIND(",",$J$2:$J$12)+1,256))=L2,$E$2:$E$12))=1,1,0)
This formula is also an array formula.
See image for reference:

Resources