Two parameter search in Excel - excel

I have an excel datasheet having data in the following order:
The first row in the dataset states that an Apple has 3 quality standards (A, B & C) and the price for each particular quality is on that row.
I would like to create a search functionality that allows the user to enter the name of fruit and quality and it would give the respective price.
Can someone help me how to approach this? I don't think a simple VLOOKUP would suffice my requirement. Thanks.

You can still use VLOOKUP, but with MATCH to specify the column index you want to return the value from.
=VLOOKUP(G2,A2:D4,MATCH(G3,A2:D2,0),FALSE)
In this case, the lookup value for VLOOKUP is the fruit name, the table range is the table containing the fruit, quality, and price, and the search type is exact. The third parameter, instead of having a number indicating what column, uses the MATCH formula. The first parameter is the value to look up (the entered quality), the second parameter is the header row of your table containing the qualities, and the third parameter indicates an exact search. MATCH will return a number containing the index of the column that matches the entered quality, and that is the column index used by VLOOKUP.

Related

Is there a way to see if a given value exists in a row identified via VLOOKUP and, if so, return the value in another cell in that row?

I have an Excel data set that summarizes shipping surcharges by tracking number. I have the tracking number in Column A as my Index, but the data is presented such that to the right of the tracking number in Column A, I have pairs of columns that dictate Charge Type and $ Charge to the right of the tracking. The column Headers are generic for the Surcharge Type and Surcharge Amount, so the columns are not fixed. As such, Column B (the first Surcharge Type for any given tracking number) could either be blank OR contain any of a subset of applicable tracking surcharges, with the charge amount associated with that surcharge type being presented in Column C (otherwise it is $0). I want to recreate the data set with my tracking numbers in Column A, all of the possible surcharge types fixed as the column headers (beginning in Column B), and the body of the table containing only the charge amounts, in $, for a given combination of tracking number and surcharge type.
See current format and desired format as follows.
Current:
enter image description here
Desired:
enter image description here
How can I most efficiently code this in Excel?
Now, what if I tell you that a given tracking number can show up more than once in Column A (i.e. adjustments to prior charges). How does this change the formula?
THANK YOU!
The following formula might work:
=IFERROR(INDIRECT("<sheetname>!"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),MATCH(<columnHeader>,INDIRECT("<sheetname>!"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),2)&":"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),<max#ofSurcharges*2+1>)),0)+2)),0)
It essentially finds the row of the tracking # on the first sheet and creates an array in which to search for the surcharge name and if it finds the surcharge it will return the value of the adjacent cell, which is the associated value.
Please note that this formula is somewhat dependent on the structure of the raw data: tracking numbers must be in column A and the surcharges need to start in column B.
Also this will only find the first instance of the tracking number in the list, so I suggest adding some form of timestamp to sort your raw data, if you need to use the latest entry.
Edit: a solution using VLOOKUP might be more efficient, not sure
Edit2: The problem with VLOOKUP is that the raw data is no proper table like the edited data. Really the best solution would be to enter 0 values in the first place, not afterwards.
Anyway, this solution is fairly similar to the above, but uses VLOOKUP to retrieve the data in the end. If you are dealing with large sets of data you can test which method is more efficient.
=IFERROR(VLOOKUP(<Tracking#>,<referenceToRawData>,MATCH(<columnHeader>,INDIRECT("<sheetname>!"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),2)&":"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),<max#ofSurcharges*2+1>)),0)+2,FALSE),0)

Return last date something was entered into one column with criteria from another column

I'm working with a set of data in excel. Data is entered into rows for items specified in columns. The first column contains a date. A cell in the same row of one of the columns contains the name of a person and in another cell in the same row but different column may contain a number larger than zero (or it may be empty).
I need to create a formula which returns the date when a number larger than zero was last entered into that column for a specific name. This is a "living list" which keeps on growing and the same names appear in different rows, sometimes with a number in the column a mentioned and sometimes not.
I found an old thread on this site on a similar subject which got me as far as knowing the date of the last entry containing the persons name but I'm still not able to configure it to show me when that specific person also had a number larger than zero in that column.
Here's the thread: How to get the newest value from a column with conditions
My current formula looks like this:
=INDEX($A:$A,MATCH(MAX(IF($G:$G=Sheet7!C5,$A:$A,0)),IF($G:$G=Sheet7!C5,$A:$A,"")))
CTRL+SHIFT+ENTER
Column A contains the dates
Column G contains the names (and "Sheet7!C5" is a reference to a name)
The value column I need to add to the mix is column AY
I feel there must be a simple solution (a small add on to the formula) to solve this but I always end up with an error.
Thanks in advance :)
Edit: Here is a simplified example of the data entry and output list needed.
For this you need to sort the date DESCENDING and format the table as Excel Table
Edit: you can sort the date ascending. See explanation at the end.
Using your example, then the formula will be
=INDEX(TableData[Activity A], MATCH($B14, TableData[Employee initials], 0))
This works just like the usual VLOOKUP or INDEX MATCH, fetching the first date on an activity matching the employee initials.
You can use VLOOKUP, but you'll need to dynamically name the range of each columns.
Edit: Just today I found an interesting behavior of MATCH when it found multiple matching values. If you use 1 instead of 0, then it will fetch the last matching value on the list.
So, you can use this formula instead in ASCENDING table.
=INDEX(TableData[Activity A], MATCH($B14, TableData[Employee initials], 1))

List top 5 scores AND names associated with those scores

My Numbers spreadsheet has a column of summed scores (AA) from a gymnastics meet, the All-Around scores. Each score in this column is associated with a specific gymnast name in another column (Name).
What I'm trying to do is populate a smaller spreadsheet that will parse the top 5 (or more) scores AND names associated with those scores into two columns - one for names, the other for scores.
This should be something very simple, but I haven't ever played with Excel or Numbers and am really struggling to make sense of all the syntax and formulas.
I've created a link to an image of the columns in question for reference.
https://www.dropbox.com/s/5w819hz1iyhpdde/Scores.jpg?dl=0
Create a pivot table and the set the Top 10 (you can set later to any number)
More info:
http://www.contextures.com/excel-pivot-table-filters-top10.html
This can be broken down into three steps.
Let's say you need the 5th largest element.
Use Large to get the 5th largest element. LARGE(b:b, 5)
The above returns the 5th largest value in the b:b range. But you need to know which row number this is in the B column. For that we use MATCH. Use, MATCH(lookup value, range, 0) where lookup value is the one returned in the first step, range is again B:B and 0 means exact match.
We need to find the appropriate name associated with the largest value. We use INDEX, which finds the value at a particular index value. Use, INDEX(name range, row_number) where name range is say A:A and row_number is the one returned in the previous step.
To sum it up, you need:
INDEX(A:A, MATCH(LARGE(B:B,5),B:B,0)) to get the 5th largest name. Change 5 to whatever rank you want!

Searching for a cell in a column and if it exists returning an adjacent value in Excel

![enter image description here][1]Afternoon Guys,
I saw a couple threads that were similar to what im looking to do.. but from what Ive tried so far I cant get this working.
Im trying to make a formula that takes a cell (Green on the left), searches for it in a column (green column on the right) and then if found returns the adjacent value (in blue)
Can anyone get me started on this?
Ok, apparently I cant post images yet....
See VLookup.
You can use the VLOOKUP function to search the first column of a range of cells, and then return a value from any cell on the same row of the range. For example, suppose that you have a list of employees contained in the range A2:C10. The employees' ID numbers are stored in the first column of the range...If you know the employee's ID number, you can use the VLOOKUP function to return either the department or the name of that employee.
The format for VLOOKUP is (lookup value, search array, index number, match type) where:
lookup value is the thing you are searching for (A14)
search array is the table where you plan to get the data back from, where the far-left column contains the lookup values you are searching against (judging from your comment, you will need to move things around)
index number is the 1-based index of the column that has the value you want to return. The key column (far left) is 1, and increases in your range as you go right
The fourth parameter needs to be false in almost all cases.
Keeping in mind that VLOOKUP will return on the first match it finds from the top of the list, regardless of how many matches there are.

Compare two columns for match or partial match, copy value from third column into fourth column

As the title says, I need to compare two columns for a match or partial match and then copy a value from a third column into a fourth column.
A condensed version of my issue below:
I need to compare the product ID and the supplier product ID (be it match or partial match) then copy the supplier product price into the new product cost column.
I am having limited success with my VLookup formula for matching product ID's as I only know how to do exact matches and not partial matches.
Not every line of the supplier product ID has data in it, nor is the product ID list and the supplier ID list the same length.
The spreadsheet has approximately 2000 products in it.
Any help is greatly appreciated! :)
From your description, this formula copied into C3 will work for you.
=IF(ISNUMBER(SEARCH(A3,MID(F3,2,3))),G3, IF(ISNUMBER(SEARCH(MID(F3,2,3),A3)),G3, IF(ISNUMBER(SEARCH(A3,F3)), G3, IF(ISNUMBER(SEARCH(F3,A3)), G3, ""))))
I know it looks hard, but its really just testing for equality between the middle of the ID codes, and then if either is just a substring of the other.
It not being vba also means you won't have to make it a macro enabled workbook.

Resources