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:
Related
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
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),))
I have a log where I have two columns (H&G) where I have sales people's names inputted for each row. Column I lists the row as belonging to one of three categories ("name1" "name2" or "name3").
On the next sheet in the book I have tabulations for counting how many times each person's name appears, but what I'd like to do is cross reference that with how many they appear next to each of the categories.
ie I currently can tell that Steve has 6 deals. But what I'd like to know is that Steve has 4 of name1 and 1 each of name2
edit:
So I think I've not been clear on what I'm searching for: I am trying to sum the number of times a salesperson's name appears in columns F or G that also have a string in column H.
ie: Steve's name appears 13 times, but only 8 of those are on rows that have Phone
Assuming your data is as in the image below, try following formula
=COUNTIFS($F2:$F9,J2,$H2:$H9,K2)+COUNTIFS($G2:$G9,J2,$H2:$H9,K2)
Drag/Copy down formula as required and change range as per your data.
In above formula I am assuming you want to consider Column F and column G separately for category. In case you want both Column H & G to have same name for category then use
=COUNTIFS($F2:$F9,J2,$G2:$G9,J2,$H2:$H9,K2)
This will give result 1 as only Row 5 has Steve in both Column F & G matching category Phone.
EDIT : As per #ForwardEd's comment
If you want to count row having same Name in both Column F & G only once (as in Row 5 in image), then subtract above two formulas as
=COUNTIFS($F2:$F9,J2,$H2:$H9,K2)+COUNTIFS($G2:$G9,J2,$H2:$H9,K2)-COUNTIFS($F2:$F9,J2,$G2:$G9,J2,$H2:$H9,K2)
or use
=SUMPRODUCT((($F$2:$F$9=J2)+($G$2:$G$9=J2)>0)*($H$2:$H$9=K2))
This will give result 3 for Name=Steve and Category=Phone considering Rows 2,5,8 (note : Row 5 has Steve in both Column F & G but will be counted once).
Use COUNTIFS:
=COUNTIFS(A1:A6,"steve",B1:B6,"name1")
For referencing from multiple sheets:
=COUNTIFS(A1:A6, "steve", Sheet2!A1:A6, "name1")
you can make n columns for each column you'd like to know and or you can make a single big column with multiple formulas.
You can use the & symbol to string together a long formula in a single cell.
Like:
="Month 1: "& countif(G1:G10,"Steve") & " " & "Month 2: "& countif(H1:H10,"Steve")
All that will output: Month 1: 4 Month 2: 2
you can string a lot of functions with the & symbol, so you can change the placeholder and stuff.
Also you can change the inquote string "Steve", for a reference so you'll just have to write this big formula once.
I've got a list of data which has a hierarchy of sorts. There's the primary group which then falls into secondary group which then has a tertiary group of unique data. I'm trying to figure out how to represent the number of unique secondary groups in a primary group.
E.g. Group A has a list of subgroups A-1,A-1,A-2,A-2,A-2,A-3 and Group B has a list of subgroups B-1,B-2,B-2. In here I want to show in a chart how many unique subgroups there are in a group and fraction of each, i.e. Group A has 3 subgroups; 2 A-1, 3 A-2, 1 A-3, and Group B has 2 subgroups; 1 B-1 and 2 B-2.
The increased hierarchical orders throw me for a loop. Any ideas?
Edit: I've included an example of how the data looks roughly (just several magnitudes more data)
Use this one array formula:
=SUM(IF($A$2:$A$23=E2,1/COUNTIFS($A$2:$A$23,E2,$B$2:$B$23,$B$2:$B$23)))
being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.
You can do this with a couple of helper columns.
First in Column D put this formula in D2 and drag it down:
=A2&B2
Then in Column E enter this formula as an array (paste and then press CTRL+SHIFT+ENTER) and drag it down until you get a '0':
=INDEX($D$3:$D$100, MATCH(0, COUNTIF($E$1:E1, $D$3:$D$100), 0))
Then in Column F you can start your table by entering the Alpha variables (A,B,C).
In Column G enter this formula in G2 and drag down:
=COUNTIF($E:$E,$F2&"*")
You should end up with something like this:
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.