I have a column of few thousand filenames that are not uniform. For instance:
| Column A | Column B |
===============================
| junk_City1_abunc | City1 |
-------------------------------
| nunk_City1_blahb | City1 |
-------------------------------
| small=City2_jdjf | City2 |
-------------------------------
| mozrmcity3_somet | City3 |
I would like to identify the city within the text in column A and return it in Column B.
I've come up with a complex formula that does the trick, but it is difficult to adjust if more cities are added within the filenames in new entries within column A.
Here is an example:
=IF(ISNA(MATCH("*"&$W$3&"*",I248,0)),IF(ISNA(MATCH("*"&$W$4&"*",I248,0)),IF(ISNA(MATCH("*"&$W$5&"*",I248,0)),IF(ISNA(MATCH("*"&$W$6&"*",I248,0)),IF(ISNA(MATCH("*"&$W$7&"*",I248,0)),IF(ISNA(MATCH("*"&$W$8&"*",I248,0)),"Austin","Orlando"),"Las Vegas"),"Chicago"),"Boston"),"Las Angeles"),"National")
It seems like there should be an easier way to do it, but I just can't figure it out.
(To make matters worse, not only am I identifying a city within the filename, I'm looking for other attributes to populate other columns)
Can anyone help?
Use the formula =IFERROR(LOOKUP(1E+100,SEARCH($E$2:$E$11,A2),$E$2:$E$11),A2)
This does *****NOT***** have to be array entered.
Where $E$2:$E$11 is the list of names you want returned and A2 is the cell to test
If no matches are found instead of errors you will just use the full name in column b.
If you want errors or expect to NEVER have then you can just use:
=LOOKUP(1E+100,SEARCH($E$2:$E$11,A2),$E$2:$E$11)
Here's a round about way that works, not all my own work but a mish mash of bits from other sources:
Assuming the sheet is setup as follows:
The formula to use is below, this must be entered using Ctrl+Shift+Enter
=INDEX($C$2:$C$8,MAX(IF(ISERROR(SEARCH($C$2:$C$8,A2)),-1,1)*(ROW($C$2:$C$8)-ROW($C$2)+1)))
Annotated version:
=INDEX([List of search terms],MAX(IF(ISERROR(SEARCH([List of search terms],[Cell to search])),-1,1)*(ROW([List of search terms])-ROW([Cell containing first search term])+1)))
Related
I have an excel table, like this
| DOG | CAT | COW | CHICKEN ...
------+-----+------+------+------
FARM1 | 2 | 0 | 4 | 80
------+-----+------+------+-------
FARM2 | 0 | 3 | 12 | 125
------+-----+------+------+-------
......
Is it possible to get the value through the customer headers instead of A2, B2?
I want to be able to fetch the value like so
=FARM1DOG
Is it possible to do that?
What you are describing could be done a few ways. I would prefer index(match(...
Assuming your table above is in the top-left corner of the spreadsheet and continues to J10 you could use:
=INDEX($B$2:$J$10,MATCH("FARM1",$A$2:$A$10,0),MATCH("DOG",$B$1:$J$1,0))
On the other hand, you could do it with named ranges as well, but the names would need to be changed if the column headers changed. Just name each entire column after it's header. So select column B and create a name for the range called "Dog", then the same for all the other columns. Then for the rows name row 2 "Farm1", etc...
Then you can use:
=FARM1 DOG
(the space between them is the intersect operator)
Under presumption that your data is small you can also name the Range manually:
Select the cell you want to name
Formulas -> Define Name [ CTRL + SHIFT + F3 ]
Call it whatever you want
Now you can refer to the cell by the given name:
EDIT:
Alternatively, you could also name the headers only and refer to it via =OFFSET.
=OFFSET(<VERTICAL NAME>,,COLUMN(<HORIZONTAL NAME>) - COLUMN(<VERTICAL NAME>))
In a practical example
=OFFSET(farm1,,COLUMN(dog) - COLUMN(farm1))
I have a table in EXCEL that looks like this:
ATTRIBUTE_IN_1|TYPE_IN_1|ATTRIBUTE_IN_2 |TYPE_IN_2 |
________________________________________________________
advance |String | accounts |decimal(20,10) |
education |String | Job_category |String |
date of birth |date | advance |decimal(20,10) |
and etc.
I want to compare TYPE_IN_1 and TYPE_IN_2 (2nd and 4th columns) for equal values in ATTRIBUTE_IN_1 and ATTRIBUTE_IN_2 (1st and 3rd columns).
In the result I want to see values, when ATTRIBUTE_IN_1 and ATTRIBUTE_IN_2 have equal value, but TYPE_IN_1 and TYPE_IN_2 (2nd and 4th columns) have unequal values.
For that example in result I want to see:
ATTRIBUTE_IN_1|TYPE_IN_1|ATTRIBUTE_IN_2 |TYPE_IN_2 |
_______________________________________________________
advance |String | advance |decimal(20,10) |
What formula can i use in MS EXCEL for solving this problem?
Excel doesn't really lend itself to this type of question. You can cobble something together, perhaps along these lines (for attribute 1):
=IFERROR(INDEX($A$2:$A$10,INT(SMALL(IF(($A$2:$A$10=TRANSPOSE($C$2:$C$10))*($B$2:$B$10<>TRANSPOSE($D$2:$D$10)),
ROWS($A$2:$A$10)*(ROW($A$2:$A$10)-ROW($A$2))+TRANSPOSE(ROW($A$2:$A$10)-ROW($A$2))),ROW(1:1))/ROWS($A$2:$A$10))+1),"")
This sets up a 2D array where the rows are the attribute 1's and the columns are the attribute 2's. The array elements where there is a conflict are set to 1. The rest of the formula is to get the corresponding values out in row/column order.
For type 1:
=IFERROR(INDEX($B$2:$B$10,INT(SMALL(IF(($A$2:$A$10=TRANSPOSE($C$2:$C$10))*($B$2:$B$10<>TRANSPOSE($D$2:$D$10)),
ROWS($A$2:$A$10)*(ROW($A$2:$A$10)-ROW($A$2))+TRANSPOSE(ROW($A$2:$A$10)-ROW($A$2))),ROW(1:1))/ROWS($A$2:$A$10))+1),"")
For type 2:
=IFERROR(INDEX($D$2:$D$10,MOD(SMALL(IF(($A$2:$A$10=TRANSPOSE($C$2:$C$10))*($B$2:$B$10<>TRANSPOSE($D$2:$D$10)),
ROWS($A$2:$A$10)*(ROW($A$2:$A$10)-ROW($A$2))+TRANSPOSE(ROW($A$2:$A$10)-ROW($A$2))),ROW(1:1)),ROWS($A$2:$A$10))+1),"")
It's interesting to compare this with the SQL for doing the same thing e.g. in SQLite:
.mode csv
.import book2.csv test1
select a.attribute_in_1,a.type_in_1,b.type_in_2
from
test1 a inner join test1 b
on a.attribute_in_1=b.attribute_in_2 and a.type_in_1<>b.type_in_2;
the following excel tables are given:
Sheet01
String: A
Output: B
+---------------------+--------------+
| String | Output |
+---------------------+--------------+
| ABC Test01 | It is Test01 |
| DEF Test01 | It is Test01 |
| Test01 GHI | It is Test01 |
| Hellow Test02 World | Wow Test02 |
| Test02 Sum Sing | Wow Test02 |
+---------------------+--------------+
Sheet02
Search Criteria: A
OutputThis: B
+-----------------+--------------+
| Search Criteria | OutputThis |
+-----------------+--------------+
| Test01 | It is Test01 |
| Test02 | Wow Test02 |
+-----------------+--------------+
So basically I want to find out if Search Criteria in Sheet02 can be found in String in Sheet01. If so, display in Output (Sheet01) value of OutputThis (Sheet02).
Following works for exact match:
=INDEX(Sheet02!B:B,MATCH(A2,Sheet02!A:A,0))
Now I simply tried to put in the like operator which doesn't make any sense. Because excel can't now what part of String is to be found in Search Criteria.
What I'm looking for is something
=New_Function(SearchCriteriaMatrix, SearchCell, OutputMatrix)
EDIT:
I just used the following code and it somehow works:
=INDEX(Sheet02!B:B,Match(A2,Sheet02!A:A,-1))
The key is "-1". It changes the criteria from an exact match to a broad match. At least that's what I want it to do, but it doesn't workout well. Perhaps someone can use this and help out.
SEARCH or FIND can find a substring within a string. So something like:
=LOOKUP(2,1/SEARCH(srchCritTbl[Search Criteria],A2),srchCritTbl[OutputThis])
will work.
I made your sheet2 table into a "real" table and I'm using structured references, but it'll work with discrete references also, but the references should encompass only the active part of the data table, and not the entire column.
Here is a screen shot showing the results:
If you were to use direct references to the table on Sheet02, it would look like:
=LOOKUP(2,1/SEARCH(Sheet02!$A$2:$A$3,
Sheet01!$A2),Sheet02!$B$2:$B$3)
The way this works:
SEARCH returns an array of either a number, or an error, depending on whether or not if finds the contents of table2 within the referenced cell in table 1.
1/Search(... will then return either an error, or some number which has to be no greater than 1.
Using 2 as the lookup criteria in LOOKUP guarantees that it will be greater than any value returned in the lookup_vector.
If the LOOKUP function can't find the lookup_value, the function matches the largest value in lookup_vector that is less than or equal to lookup_value. EDIT: As pointed out by #Gregory, this applies if lookup_vector is sorted ascending. When it is not, then the last entry that is less than or equal to lookup_value gets matched.
since result_vector references the OutputThis column, the matching entry in that column would be returned.
One could also guarantee, in this situation, that lookup_value would be greater than any value in lookup_vector by using a very large number, and eliminating the 1/... portion:
=LOOKUP(9.9E+307,SEARCH(srchCritTbl[Search Criteria],Sheet01!$A2),srchCritTbl[OutputThis])
I used the other form out of habit as it is more generally useful.
Here's a single cell array formula:
In cell Sheet01!B2 type:
=INDEX(Sheet02!B:B,MATCH(1,IF(ISERROR(SEARCH(Sheet02!A:A,A2)),0,1),0))
Press ctrl+shift+enter to complete the formula as single cell array formula
Copy this cell down to the remaining range Sheet01!B3:B6
Note: It gives the output for the first Sheet02 Search Criteria that matches, and not the first one found in the string. So the string Test02 and Test01 would output It is Test01 because Test01 is listed before Test02 on Sheet02.
I'm trying to count values in Column A if Column B matches a certain string of text.
assets status
-----------------------------
1 | itemThing | yes
2 | |
3 | itemThing |
4 | |
5 | itemThing | yes
This above example would ideally return 2.
I want to count how many times "item" shows up in column A ONLY if column B says "yes"
I've tried something with =SUMPRODUCT but it doesn't seem to work correctly. It is currently returning 4 when there are 5 matching criteria.
I have =SUMPRODUCT((assets=A1)*(status=B1)) where assets and status are custom names for the column ranges created with Name Manager.
Edit: noticed that is has to be an exact string match for it to count correctly. How do I do partial string matches? e.g. search terms? e.g. match =SUMPRODUCT((assets="*item*")*(status=B1))
Two ways here for your reference:
SUMPRODUCT:
=SUMPRODUCT((ISNUMBER(SEARCH("*itemThing*",assets)))*(status="yes"))
COUNTIFS:
=COUNTIFS(status,"yes",assets,"*itemThing*")
For partial match, use wild card * such as "*itemThing*" and that should do the trick for you.
I have a data set as follows:
A | B | C |...
1abc | 1def | 1ghi |...
2abc | 2def | 2ghi |...
...
This is a collection of memo notes for each account in our database. The 1 in "1abc" represents the account ID and the letters represent some text. There are a total of 177 columns and 1866 rows but not every row has values up to column 177, some may only have two columns worth of data.
I need each column to drop down to the bottom of column A so that all data only occupies Column A. For example, all the data in column B would inserted after the last value in A. Data in column C would be inserted after the last value in column A after it's been populated with the data from B and so on.
In the end, it should look something like this (from which point I can simply sort it in ascending order).
A | B | C |
1abc | | |
2abc | | |
...
1def | | |
2def | | |
...
1ghi | | |
2ghi | | |
...
Can anyone help out with this? I am assuming that I need a macro and have tried working with the solution found in this post but couldn't figure it out. Oh, and I'm using Excel 2003 if that helps.
I am not sure if this will help but, from what you have given me, it sounds like you have 3 columns of data that you would like to be put into one column. If I am correct in my thinking, you can do this a few different ways. So as to preserve the original document in its entirety while adding an extended sorting system you could: 1: Create new tab. Then highlight range a with your mouse. Using your mouse right click and select copy (try to keep in mind the value of the range, E.g. How many items have you copied. Paste it in your now tab. Do this for the remaining ranges. Or maybe use V look up. If you would like I have a schedule module I have created that has many different types of range associations. You can also split sting in excel to divide the id from the sting.
Without VBA, add a blank row at the top and a column on the left populated throughout with say x and then follow the steps detailed here. Then delete the left-hand two columns and filter the remaining one to remove any blanks.