Extracting Data from a line - excel

I have some data that looks like this (This is real countries but no sensitive data) It is formatted exactly like i posted
Calgary, Alberta T2P 0B3 Canada
Thunder Bay, Ontario P7G 0A1 Canada
Toronto, Ontario M3A 1E5 Canada
Calgary, Alberta T2G 1C6 Canada
Calgary, Alberta T2N 1C2 Canada
Edmonton, Alberta T5J 2W8 Canada
New Westminster, British Columbia V3L 5T4 Canada
London, Ontario N6A 5P6 Canada
Guelph, Ontario N1G 2W1 Canada
Whitby, Ontario L1N 4Z1 Canada
Red Deer, Alberta T4R 0L4 Canada
Edmonton, Alberta T5H 0S2 Canada
West Kelowna, British Columbia V4T 3E3 Canada
I am trying to get the Canadian zip code (N6A 5P6, N1G 2W1, etc) in 1 cell (so 1 cell per line with the zipcode.
So it will look like
Original data, zip code
original data, zip code
I figured out how to do it for american zip codes, but that space is messing me up. Thank you.

I think this should work, assuming it always ends with Canada:
=MID(A1,SEARCH("Canada",A1)-8,8)

You could split the content on spaces and just drop the final content of the split (which will always be Canada), preserving the elements at index -2 and -3 (the zip elements)

Related

How to link the content of two cells

I have an excel file with 2 different sheets. In one i have a list of cities, in the other one i have all the trains that go in that specific city. I have linked the city's name cells with the corresponding in the list. If i add another city and reorganize the list in alphabetic order the trains sheet will have the city's names all changed. How can i connect the content of two different cells so that if i reorganize the list the names in the trains sheet will not change? I looked gor a solution in the official microsoft forum but i didn't find anything
I'm using VLOOKUP() function and it works
In CITIES-STATIONS.xlsx file I'm taking 3 columns as array I'm
getting the column 3 to show in Trains.xlsx file
I added Florida City and is taking the value of the station the formula is in the Trains.xlsx file:
=VLOOKUP(B2,'[1-CITIES-STATIONS.xlsx]Stations'!$A$1:$C$44,3,FALSE)
=VLOOKUP(Searching Value, Array ,Column to get in to the Trains File, Bolean Value in case null)
1-CITIES-STATIONS.xls file
A B C
City State Station Name
Alpine TX (ALP)
Alton IL (ALN)
Arkadelphia AR (ARK)
Austin TX (AUS)
Benson AZ (BEN)
Bloomington IL Uptown Station (BNL)
Carlinville IL (CRV)
Chicago IL Union Station (CHI)
Cleburne TX (CBR)
Dallas TX Union Station (DAL)
Del Rio TX (DRT)
Deming NM (DEM)
El Paso TX Union Depot (ELP)
Florida MI Amtrak Florida <------
Fort Worth TX (FTW)
Hope AR (HOP)
2-TRAINS.xls file
A B C
Train Company City Station
Amtrak. Malvern (MVN) <---formula here
Amtrak. Arkadelphia (ARK)
Amtrak. Palm Springs Amtrak Station (PSN)
Amtrak. Florida Amtrak Florida <------
Norfolk Southern Railway. Hope (HOP)
Norfolk Southern Railway. Texarkana (TXA)
Norfolk Southern Railway. Marshall (MHL)
Norfolk Southern Railway. Longview (LVW)
Norfolk Southern Railway. Mineola (MIN)
Union Pacific Railroad. Dallas U.S. (DAL)
Union Pacific Railroad. Fort Worth (FTW)
Union Pacific Railroad. Cleburne (CBR)
Union Pacific Railroad. McGregor (MCG)
Union Pacific Railroad. Temple (TPL)
Union Pacific Railroad. Taylor (TAY)
BNSF Railway. Austin (AUS)
Good luck!

Excel formula for aggregation and filtering

Is it possible to aggregate values on one excel tab and display on another tab?
In addition to that can we also filter on one of the columns as we aggregate?
For example, Sheet1 has 3 columns - (Continent, City, Ignore)
Continent City Ignore
Europe Paris N
Europe London N
Europe Liverpool N
Europe Rome N
Europe Oslo Y
Asia Tokyo N
Asia Osaka N
Asia Dubai N
Asia Bangkok Y
Asia Mumbai N
Africa Cairo Y
I want my Sheet2 to display the number of cities per continent taking into account the "Ignore" flag.
Continent #Cities
Europe 4
Asia 4
Africa 0
Since 3 Cities are marked as Ignore=Y, we don't want to count them.
It came as one of the recommended pivot tables, but I'm trying to build this using excel formulas so I can build on that if needed.
Prefer excel formulas over VBA or Macro.
Using your sample data...
Formula in F2:
=COUNTIFS($A$2:$A$12,E2,$C$2:$C$12,"N")
Drag down...

Convert address into country

I have a panda table which has many countries as location based. The table is shown link this
Real Table |After conversion
Edinburgh, Scotland |UK
Nairobi, Kenya| Kenya
Manchester| UK
uk |UK
Sirajganj |Bangladesh
How to do that in python?
or coordinated to the country?
+05.0738+047.3288 to Somalia
+60.45148+022.26869 to Finland
+51.50853-000.12574 to United Kingdom
+33.24428-086.81638 to USA
+47.55839+007.57327 to Switzerland
This program is solved using Yandex python.
import geocoder
g = geocoder.yandex([55.95, 37.96], method='reverse')
print(g.json)
g.json['country']

Excel validation dropdown long list

Does excel dropdown validation list have a limit.
Trying to put the list of states but it doesn't show all of them:
Source: Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Delaware, District of Columbia, Florida, Georgia, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma, Oregon, Pennsylvania, Rhode Island, South Carolina, South Dakota, Tennessee, Texas, Utah, Vermont, Virginia, Washington, West Virginia, Wisconsin, Wyoming
Place all 50 States in a column (you can hide the column), then allow a List and select the cells with the States
Put the list in a worksheet and reference that instead of putting the list in manually:
There are limits to the number of items that will show in a data validation drop down list:
The list can show up to show 32,767 items from a list on the worksheet.
If you type the items into the data validation dialog box (a delimited list), the limit is 256 characters, including the separators.
From http://www.contextures.com/xlDataVal08.html#itemlimit

Excel Charts for table with many duplicates

I have a list of names with 1000 entries and maybe 750 unique. There are other attributes, like location and position. Can I create a pivot table that would show me simple stat's like X number of unique people, X number unique in location 1, location 2, location 3, and finally x number of positions in location 1, position 2/location1, position 3/location2...?
Name Location Title
Smith, Bob UK Sales Manager
Smith, Bob UK Plant Manger
Jones, Keith UK Sales Manager
Jones, Keith UK Plant Foreman
White, Derick Denver Sales Manager
Brown, Frank Boston Supply Chain
Black, Jay Denver Sales Manager
Smith, Jeff Denver Sales Manager
Gonzalez, Al UK
Gonzalez, Al UK Staging Area Manager
Bright, Susan Denver Legel Secretary
Bright, Susan Denver Paralegal
Bright, Susan Denver Executive Assistant
Bright, Susan Denver Press Secretary
Alf, Jeff Denver VP, Sales
Green, Burt Boston VP, Sales
Jones, Chuck Denver Plant Foreman
Alten, Cory Denver Sales Manager
Clark, Jerry Boston Plant Foreman
Romo, Tom Denver Sales Manager
You may want to consider using CountifS functions in adjacent columns to the data. For example to count unique people, just create a column (call it column x for this example) and enter =Countif(Column A, A1) and copy down for all the rows. then just enter =countif(Column X, 1) and that should give you the unique names.
You can use CountifS function for more complicated counting logic to answer the other questions.
I have done similar counting of unique entries using pivot tables.
I create a additional column that has a 1 if it is the first occurance of the "key" (ie name). The formula is similar to this: (assume Column A has the "key")
=IF(ROW(A1) = MATCH(A1,A:A,0),1,0)
This formula is then copied down for every row (or if it's a proper table, it's auto copied!)
The idea is that the MATCH returns the row number of the first occurrence of "key". If it is the same as the current row, then count 1. If the values aren't the same, it's a duplicate, so give it a 0 value.
When you then do a pivot table sum on this value, it adds up to the number of unique entries. (ie unique names in a region.)

Resources