Return number count of other variables based on one match in same column

Tdaddy4

New Member
Joined
Nov 7, 2019
Messages
6
Office Version
  1. 365
I have a the first column that has a list of IDs duplicate numbers
i have a second column that has a list of all facilities that are linked to that first column

i want to create a table that list all the associated facilities by the first column where at least one name is in the second column

so I want a count of facility ID and a list of the city name for a facility ID that are filtered on a certain name.
So how many Facility IDs have the word Stockton listed, and a list of the other names in that same facility ID

I need to show the most cities that match up to a filtered city based on Facility IDs


Facility IDCity
000144ANCHORAGE
000144ANCHORAGE
000144ANCHORAGE
000144ANCHORAGE
000144ANCHORAGE
000144EMERYVILLE
000166W SACRAMENTO
000166YAKIMA
000166YAKIMA
000168WHITE PINE
000168SALT LAKE
000180STOCKTON
000180STOCKTON
000180TACOMA
000180TACOMA
000459SACRAMENTO
000459PORTLAND
000480LODI
000480SACRAMENTO
000480STOCKTON
000480SALEM
000481STOCKTON
000481STOCKTON
000482STOCKTON
000482STOCKTON
000483SAN FRANCISCO
000483SAN FRANCISCO
000484VEGAS
000484VEGAS
000485N VEGAS
000485N VEGAS
000486VEGAS
000486VEGAS
000487VEGAS
000487VEGAS
000488VEGAS
000488VEGAS
000489VEGAS
000489N VEGAS
000490SACRAMENTO
000490SACRAMENTO
000491WEST SACRAMENTO
000491SACRAMENTO
000492WEST SACRAMENTO
000492SAN JOSE
000493ELK GROVE
000493ELK GROVE
000494FAIRFIELD
000494FAIRFIELD
000788STOCKTON
000788WAY
000857VALLEJO
000857PORTLAND
000857PORTLAND
000857PORTLAND
000857PORTLAND
000866FAIRFIELD
000866MULTNOMAH
000866EVERETT
000866SEATTLE
000866SEATTLE
000882FRESNO
000882NAMPA
000882NAMPA
000882NAMPA
001015W SACRAMENTO
001015SEATTLE
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
what version of excel do you have

UNIQUE()
will give you a list of Unique ID and name

so then you can do the counts etc

OR a pivot table - with a page filter

But I'm not clear on what you want to show as the output - or just filter this list


can you show what the output filtered you are after ?

Book18
ABCDEFGHIJ
1Facility IDCityFacility IDCityCitySTOCKTON
2144ANCHORAGE144ANCHORAGE
3144ANCHORAGE144EMERYVILLERow LabelsCount of Facility ID
4144ANCHORAGE166W SACRAMENTO1801
5144ANCHORAGE166YAKIMA4801
6144ANCHORAGE168WHITE PINE4811
7144EMERYVILLE168SALT LAKE4821
8166W SACRAMENTO180STOCKTON7881
9166YAKIMA180TACOMAGrand Total5
10166YAKIMA459SACRAMENTO
11168WHITE PINE459PORTLAND
12168SALT LAKE480LODI
13180STOCKTON480SACRAMENTO
14180STOCKTON480STOCKTON
15180TACOMA480SALEM
16180TACOMA481STOCKTON
17459SACRAMENTO482STOCKTON
18459PORTLAND483SAN FRANCISCO
19480LODI484VEGAS
20480SACRAMENTO485N VEGAS
21480STOCKTON486VEGAS
22480SALEM487VEGAS
23481STOCKTON488VEGAS
24481STOCKTON489VEGAS
25482STOCKTON489N VEGAS
26482STOCKTON490SACRAMENTO
27483SAN FRANCISCO491WEST SACRAMENTO
28483SAN FRANCISCO491SACRAMENTO
29484VEGAS492WEST SACRAMENTO
30484VEGAS492SAN JOSE
31485N VEGAS493ELK GROVE
32485N VEGAS494FAIRFIELD
33486VEGAS788STOCKTON
34486VEGAS788WAY
35487VEGAS857VALLEJO
36487VEGAS857PORTLAND
37488VEGAS866FAIRFIELD
38488VEGAS866MULTNOMAH
39489VEGAS866EVERETT
40489N VEGAS866SEATTLE
41490SACRAMENTO882FRESNO
42490SACRAMENTO882NAMPA
43491WEST SACRAMENTO1015W SACRAMENTO
44491SACRAMENTO1015SEATTLE
45492WEST SACRAMENTO
46492SAN JOSE
47493ELK GROVE
48493ELK GROVE
49494FAIRFIELD
50494FAIRFIELD
51788STOCKTON
52788WAY
53857VALLEJO
54857PORTLAND
55857PORTLAND
56857PORTLAND
57857PORTLAND
58866FAIRFIELD
59866MULTNOMAH
60866EVERETT
61866SEATTLE
62866SEATTLE
63882FRESNO
64882NAMPA
65882NAMPA
66882NAMPA
671015W SACRAMENTO
681015SEATTLE
Sheet1
Cell Formulas
RangeFormula
E2:F44E2=UNIQUE(A2:B68)
Dynamic array formulas.


Note: Images are difficult to see , and also requires that I input all the data myself, which is very time consuming.

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

XL2BB is an add-in used on this forum , see my signature or the menu in post to link to the full details
OR put the sample spreadsheet onto a share
I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.

Here is the link to XL2BB instructions

 
Upvote 0
I am using 365

apologize for not stating the question correctly
so for every instance i filter for a city i would like to return the other citys not just the count

so if filter is Stockton
how many instances where the facility code has a stockton in it, return the other cities

trying to find the top 5 other common cities to stockton across the other facility codes.
 
Upvote 0
I am using 365

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
so if filter is Stockton
how many instances where the facility code has a stockton in it, return the other cities
Is that what i gave in the pivot table in the XL2BB output ?

so for every instance i filter for a city i would like to return the other citys not just the count

not sure i understand that - can you please provide a few examples of results needed
 
Upvote 0
i have a giant list of facility IDs, that are unique to a group of cities.
can be a different group of cities to these unique facility ids.
i want to do something, where i filter a city, such as stockton.
and it list a the other cities that are tied to it, in each instance of a facility ID

so Stockton maybe in 1000 different facility IDs
I want a count of the other cities in each of the different facility ids, but also need to know their names, so i can say Sacramento has 900 of the same facility ids as stockton and then down the chain for the top 10 shared

and easily change the filtered city to see which they have in common.
 
Upvote 0
i was trying a pivot table, but he just gives the counts of the filtered can get a view of the info in POWERBI, but can't export the data, need to export each filtered city to share
 
Upvote 0
maybe is is better to say i want a list with a count number on how many times a filtered city matches to other cities based on the facility ID

Stockton (filtered city)

Sacramento 10 (that Stockton and Sacramento share 10 Facility IDs)
San Jose 8 (that Stockton and San Jose share 8 Facility IDs)

then a second one

Sacramento (filtered city)

San Jose 11 (Sacramento and San Jose share 11 Facility IDs)
Stockton 10 (Sacramento and Stockton share 10 Facilty IDs)
Oakland 8


that sort of things (facility IDs are unique, but will have matches between cities, so several rows with same facility id, but different info in column's
 
Upvote 0
This is a pretty clunky way of doing what I think you need to do
sure there will be a better solution from more experienced members
This is how i have done it

Column E and F
=UNIQUE(A2:B68)
which brings back the unique entries for those cities and IDs
basically removing ALL duplicates of City & ID with the same info

G2
has a data validation dropdown listing all the Unique Cities in F

H2
=FILTER(E2:E44,F2:F44=G2)
which then list all the Facility Ids - BUT only unique - could not work out how to get all the IDs and City Names associated with all those IDS

Hence
I2
=TRANSPOSE(H2:H21)
Now this will transpose all those Facility IDs horizontally
if you change the range H2 to H21 so that it has the maximum possible entries you may have - then it will not transpose across loads of columns unnecessarily
as we go from H2 to H21 - that is 19 possible entries - when transpose that will use 19 columns - so here is where you can reduce to the maximum possible IDs for 1 city

Now we have all the possible Facility IDs , which have the City name in , going along the ROW from I2 to AB2

In I3 - I have used
=IF(I2=0,"",FILTER($F$2:$F$44,$E$2:$E$44=I2))
So if the ID is zero, ie NO ID - then it blanks those cells - Hence the blank cells in the range I3:AB3

I then filter the City Column F , based on the ID in I2,J2, K2 etc etc
Which means under that ID it will list ALL the cities it finds for that Facility ID

anyway , as i say a bit clunky - bit here is the XL2BB format , and i have also but a link on dropbox , BUT i dont leave the dropbox file available for more than a few days

Stockton-ETAF.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
1Facility IDCityFacility IDCityFilterFacility IDs
2144ANCHORAGE144ANCHORAGESTOCKTON180180480481482788000000000000000
3144ANCHORAGE144EMERYVILLE480STOCKTONLODISTOCKTONSTOCKTONSTOCKTON               
4144ANCHORAGE166W SACRAMENTO481TACOMASACRAMENTOWAY
5144ANCHORAGE166YAKIMA482STOCKTON
6144ANCHORAGE168WHITE PINE788SALEM
7144EMERYVILLE168SALT LAKE
8166W SACRAMENTO180STOCKTON
9166YAKIMA180TACOMA
10166YAKIMA459SACRAMENTO
11168WHITE PINE459PORTLAND
12168SALT LAKE480LODI
13180STOCKTON480SACRAMENTO
14180STOCKTON480STOCKTON
15180TACOMA480SALEM
16180TACOMA481STOCKTON
17459SACRAMENTO482STOCKTON
18459PORTLAND483SAN FRANCISCO
19480LODI484VEGAS
20480SACRAMENTO485N VEGAS
21480STOCKTON486VEGAS
22480SALEM487VEGAS
23481STOCKTON488VEGAS
24481STOCKTON489VEGAS
25482STOCKTON489N VEGAS
26482STOCKTON490SACRAMENTO
27483SAN FRANCISCO491WEST SACRAMENTO
28483SAN FRANCISCO491SACRAMENTO
29484VEGAS492WEST SACRAMENTO
30484VEGAS492SAN JOSE
31485N VEGAS493ELK GROVE
32485N VEGAS494FAIRFIELD
33486VEGAS788STOCKTON
34486VEGAS788WAY
35487VEGAS857VALLEJO
36487VEGAS857PORTLAND
37488VEGAS866FAIRFIELD
38488VEGAS866MULTNOMAH
39489VEGAS866EVERETT
40489N VEGAS866SEATTLE
41490SACRAMENTO882FRESNO
42490SACRAMENTO882NAMPA
43491WEST SACRAMENTO1015W SACRAMENTO
44491SACRAMENTO1015SEATTLE
45492WEST SACRAMENTO
46492SAN JOSE
47493ELK GROVE
48493ELK GROVE
49494FAIRFIELD
50494FAIRFIELD
51788STOCKTON
52788WAY
53857VALLEJO
54857PORTLAND
55857PORTLAND
56857PORTLAND
57857PORTLAND
58866FAIRFIELD
59866MULTNOMAH
60866EVERETT
61866SEATTLE
62866SEATTLE
63882FRESNO
64882NAMPA
65882NAMPA
66882NAMPA
671015W SACRAMENTO
681015SEATTLE
stockton
Cell Formulas
RangeFormula
E2:F44E2=UNIQUE(A2:B68)
H2:H6H2=FILTER(E2:E44,F2:F44=G2)
I2:AB2I2=TRANSPOSE(H2:H21)
I3:I4,M3:M4,K3:L3,N3:AB3,J3:J6I3=IF(I2=0,"",FILTER($F$2:$F$44,$E$2:$E$44=I2))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
G2List=$F$2:$F$44


 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,834
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top