Index Match Partial Criteria - excel

I'm trying to Index/Match a column with shortened criteria. The idea is to Pull the Line of Business from the column without producing dozens of "duplicate" Unique Lines of Business.
Currently, I get a list like:
Whereas I just want:
I don't want to use a fixed list lookup, as the data is varied enough to not be practical using a fixed list
The ARRAY formula so far: {=IFERROR(INDEX($C$1:$C$155,MATCH(0,COUNTIF($Q$156:Q156,$C$1:$C$155)+COUNTIF($C$1:$C$155,$C$1:$C$155<>1),0)),"")}
Is there a way to search in the text for the company name without creating a new column?

You would need to use some sort of formula like this to filter your countif query =IF(ISNUMBER(SEARCH("company",A1)),"Company "&MID(A1,FIND("company",A1)+8,1),"").
This code searches your list for the word company and then outputs the word "Company" then searches 8 positions to the right from the start of the word and returns the number.

Related

Using VLOOKUP and not only match on first value

I'm trying to use VLOOKUP to match activities with product codes, but run into an issue since VLOOKUP always returns the first match. I did a mockup below to describe my issue. To the left, I have a table with activity names and product codes.
To the right, in column G, I want to, based on matching activity names in column F with activity names in column A, assign the activities product codes from column B.
When I use VLOOKUP, it only matches with the first activity name and give all the activities with the same name the same product codes. I need them to get different product codes even if they have the same name. I want my function to "take the next one" on the list, when the first one is taken.
Should I try to use another function to solve this? Is it impossible with VLOOKUP? My 'real' document has like 2000 rows, and the solutions I found on Youtube was not good to scale.
Thanks in advance. I'm new to here so if I should clarify my question in any way, feel free to tell me.
If the raw is around 2,000 rows, you can use a nested index match with helper columns.
Add a rank in column C with the formula =COUNTIF(A2:$A$2,A2)
Then apply the same ranking in your output part as well (Ensure Activity Name is sorted so that the formula works), Output rank formula =IF(J2=J1,I1+1,1)
Formula that lists out the Product Code {=INDEX($B$2:$B$3190,MATCH(I2,IF($A$2:$A$3190=J2,$C$2:$C$3190),0))}
This is an array formula, you get the curly brackets by hitting control+shift+Enter instead of just Enter upon keying in the formula
If you are using excel 365, you can use UNIQUE formula.
=UNIQUE(A2:B18)

Extract a Word from String Containing a Specific Multiple Words

"I'm setting up a pivot in excel, and want to extract specific words from a data set of text.
I have tried using the below formula to extract one particular word, but want to nest the multiple formula to extract other words as well
=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",99)),MAX(1,FIND("Evaluation",SUBSTITUTE(A1," ",REPT(" ",99)))-50),99))
The above formula works but only for one word. I want to create nested formula to search first word or second word or third...
If your goal is to search an array for a a substring, if that substring matches any words in a list, and if so, return the matched substring, as in the post suggested by JvdV, use the formula below, which I have modified.
I recommend, in a different worksheet, add a table with a list of the words you want to find, like this. Highlight the range of cells, including the header, then Home > Format as Table > pick a table style and give it a name. This table's name is "t_WordsToFind" (so I can easily identify it in other functions later). You may want to also put your primary data into a table as well. My go-to name is usually "t_Data". Now, instead of worrying about column numbers/letters, you have the user-friendly column headers you started with which makes reading the formula much easier. Your table ranges will also automatically expand when addtl data is added, so row numbers don't need to be referenced any more either.
If you don't have your data in tables, use this version of the formula, and remember to update your range parameters when data is added. B2 is the first cell to be searched, D2:D4 is the list of words to look for, copy the formula down. I do prefer not to use IFERROR as it includes many different types of errors that I may need to know about, like if I misspelled the function name, for example. If you simply need to have an alternative in the event no matches are return and your function is valid, I recommend IFNA.
IFNA(LOOKUP(1,1/COUNTIF(B2,"*"&$D$2:$D$4&"*"),$D$2:$D$4),"")
If you do use tables for your data and lookup tables (you are very wise) and here is the formula version to use (below). In this example, #[Search This Column] is the the equivalent to B2 and t_WordsToFind[Find This] is the table name and column name of words to look for, but it's much more legible, and doesn't need to be copied down or manually expanded in the future.
IFNA(LOOKUP(1,1/COUNTIF([#[Search This Column]],"*"&t_WordsToFind[Find This]&"*"),t_WordsToFind[Find This]),"")
Even wiser still, assuming this is a perpetual need, would be to use power query/power pivot, but I don't want you to go into TMI overload.
Also, your pivot table range will be nice and easy, "t_Data".

How to sumif the vlookup value of a range?

I'm not sure how to explain what I am trying to achieve so I will start with the data I am working with:
1) A table that lists IDs corresponding to Games. Each game has several IDs.
2) A table that lists IDs and $ Earned on those IDs.
In another table, I have the list of games and want to return the sum of $ Earned on those games:
Tables 1,2,3
I was trying to do this with a combination of a SUMIF and VLOOKUP formula but I can't seem to find a way to do that because the VLOOKUP returns a value rather than a range. What I want to do is sum a sum_range ($ earned) if the lookup value of the range (game corresponding to the code) is a match.
I could simply add a column to the second table that returns the game of that code with a VLOOKUP. But the problem is that this would need to be done in a very large number of sheets, and with each time the new data is received.
Hopefully that made sense and thank you in advance for any help I can get!
Cheers,
Maria
Well this may be a bit of a cheat. if you look at your game code, you are either looking for basketball or baseball. So we could do a sum if the code contains one of those words.
If case sensitivity is important
=SUMPRODUCT(--(ISNUMBER(FIND("Basketball",B2:B16)))*C2:C16)
or if case sensitivity is not important
=SUMPRODUCT(--(ISNUMBER(SEARCH("Basketball",B2:B16)))*C2:C16)
B2:B16 would be your code in table 2
C2:C16 would be your $ earned column in C2
The formula would be placed where the ? cell is beside big win Basketball.
updated option for keyword
So if you are not looking for just baseball or basketball, but the entire string of the key words that you are looking for the total for, you could use the following provided the words in table three form part of the code when the spaces are removed.
=SUMPRODUCT(--(ISNUMBER(FIND(SUBSTITUTE(B19," ",""),B2:B16)))*C2:C16)
or
=SUMPRODUCT(--(ISNUMBER(SEARCH(SUBSTITUTE(B19," ",""),B2:B16)))*C2:C16)
This assumes the keyword your are looking for in the code is in B19. The substitute function removes the spaces to match your code.
In the second table add a (hidden) column, where you perform a VLOOKUP in the first table of the Code, retrieving the Game name.
Now you have something to base your SUMIF on: the value in the additional, hidden column should match the Game you have in your summary.

Display value if text strings from two ranges match

I have two worksheets in Excel. One contains the rankings:
:
The other one the matchups (daily updated automatically)
The purpose is to display the rank of each respective team in two columns next to the matchups. One of the problems is that the text strings are not exact matches (limitation of the webquery).
So I need to find a formula for when there is a string of the table in Rankings that approximately matches the specified cell for the team in matchups and then display Rank (column 1 on Rankings) next to it.
So far I've got this in the cell where the ranking is supposed to go.
=VLOOKUP("*"&qry!B5&"*";Sheet1!A3:C369;1;0)
But it just results in the string "rank" from the table header in Rankings.
Any ideas?
Several things:
Vlookup will try to find a match in the first column of the lookup table and can return a value from a column to the right. Your lookup table has the desired return value in the first column and the lookup values in the second column. Therefore, Vlookup will not work in this scenario. You can use a combination of Index and Match, though.
the * wildcard before and after the lookup value mean that the value in the lookup table can have any text before and after the text already in your lookup value. In your case, the lookup value has more text than the text in the lookup table. So the wildcard is not helping. Example: you have "353 Virginia" and you want to find this in a column that has only "Virginia". Wrapping "353 Virginia" in wildcards will add no value, because the text that you want to match is actually shorter than the text you are starting out with. You need to remove stuff from the lookup value instead of adding wild cards.
If the data for the rankings comes from a web query, you need to do some work to clean up that data, so it is fit for the lookup into your other table.
In addition to the number at the beginning, there are also two characters at the end of some cells that I cannot identify. These need to be stripped out, too, before you can do the lookup.
Assuming that all cells contain three digits and a space at the beginning you can use a formula approach
=TRIM(MID(SUBSTITUTE(B5;" ##";"");5;99))
Substitute will remove the trailing characters. I don't know what they are exactly, some web related special characters, so for the exercise here I have used ## instead of the A thing and the chevron. Copy and paste the web characters from one of your cells to the formula. With data coming from the web you may also want to check for leading and trailing white space, non-breaking space characters and other invisible characters.
You can use the "cleansing" formula as the basis of a lookup or, if the formula above sufficiently cleans the data, then you can use it in an index/match combo like this:
=index(Sheet1!$A$3:$A$369,match(TRIM(MID(SUBSTITUTE(B5;" ##";"");5;99));Sheet1!$B$3:$B$369;0))
Without seeing the actual data in a spreadsheet it is hard to tell if the formula cleanup is sufficient. You may need to do more work until a lookup returns the desired value.
If the data is coming from the web, I strongly suggest that you look into Power Query as a tool to get the data from the web into your spreadsheet. Power Query is a free add-in for Excel 2010 and 2013 and is built into Excl 2016 as "Get & Transform". It can connect to many data sources, including tables on a web page, and it has very powerful mechanisms to clean data for further processing. Once a Power Query is set up and working, all you need to do is refresh the query to load new data from the web site.

Combining a text search and a lookup table

I have a column of strings (descriptions of errors manually entered by personnel) (A2:A1000) that I'd like to search for specific words (to create categories based on the description), and based on the words found, input a specific case value (a category label) into a second column (B2:B1000). Currently this is being handled by nested if statements of the form
B2=if(isnumber(search("Flag Word 1",A2)),"Case Word 1", if(isnumber(search("Flag Word 2",A2)),"Case Word 2", ...))
Obviously for a large number of flag/case words, this gets messy pretty quickly. I'd like to be able to create a lookup table, have excel search column A for words in the lookup table, and return the corresponding value, but I'm not sure if this is possible - it doesn't seem that way without resorting to VBA. Are there any alternative methods to achieving the same result?
Thanks,
~P
You could try an array formula like this one (has to be entered with Ctrl-Shift-Enter):-
=INDEX($D$2:$D$4,MIN(IF(ISNUMBER(SEARCH($D$2:$D$4,A2)),(ROW($D$2:$D$4)-ROW($D$1)))))
It assumes that there is a list of keywords in D2:D4, and will give you the first one in the list which is contained in the string in A2. You could change MIN to MAX to get the last match.

Resources