How can I index match unique values? - excel

I asked a question a few hours ago and now I'm trying a different approach on the same issue.
I want to get the largets numbers from a table and the corresponding description.
The selected cell has the formula =LARGEST(S:S,1), =LARGEST(S:S,2) and so on...
The issue is that 4 and 5 is the exact same value which makes my INDEX MATCH formula (=INDEX(P:P,MATCH(U5,S:S,0)) U5 is selected cell) in the cell adjacent to the selected cell find the same product twice.
But if we look in the table to the right which is a copy paste values so that it can be sorted, 4 and 5th largest values are not the same product.
Can I somehow change the index match formula to the n-th of the same value so that it's "correct"?

This is a common problem. You must remove ties so your INDEX(MATCH()) can find all the matches. Consider:
Note the both Patricia and Mary have the same scores. In C2 enter:
=RANK(A2,$A$2:$A$11,0)+COUNTIF($A$2:$A2,A2)-1
and copy downwards. Column C tracks column A, but has no ties! (a simple sequential list with no duplicates or gaps)
Finally in E2 and F2 enter:
=INDEX($A$2:$A$11,MATCH(ROWS($1:1),$C$2:$C$11,0))
=INDEX($B$2:$B$11,MATCH(ROWS($1:1),$C$2:$C$11,0))
and copy these downwards.

Related

Match, Index and specific lists

I want to match specific rows and columns.
If A2 is matched with B1, then return list "ROW 1" in B2:B151
If A5 is matched with B5 then return list "ROW 4" in B2:B151
As explained in the image B2 is feed by a Dropdown from another sheet (This is not part of the question)
I am trying to override this list in B2:B151 every time a new match is made.
I haven't got a clue on how to proceed have tried multiple Index and match combination even Vlookup which is not viable for this sort of problem.
I was thinking of concatenating all these formulas in B2. The reason why I want to use Rows and columns to determine the specific match is that the data in B1 an A2:A7 is ever-changing and that's the reason why the formula needs to be dynamic.
I think this is what you want, but I'm not 100% sure of the desired final outcome.
The formula in B1 is
=OFFSET($D2,0,MATCH($B$1,PhaseArrayList,0)-1,1,1)
and you can just copy that down as many rows as you need. When you change the value in B1 it will update.
The Offset says says start at D2, go 0 rows down, go to the right the number of columns equal to the match of B1 less 1. So if C is in B1 the match returns 3 and the offset goes across 2 columns, i.e. to column F (ROW 3).
(Btw would be less confusing if you labelled them columns!)

Searching for multiple keywords in excel

I have course listings with detailed description. I have 25 keywords in order to filter particular type of course. I want to count the number of courses with the description containing more than 3 keywords. Can anyone help me how to do it?
One way...
Say course descriptions are in column A with heading in A1 and descriptions below in A2, A3, etc. Then, next to the header in following columns, we'll assume C and on to the right here, type in the keywords. Then:
//copy these down and to the right
In cell C2: =IFERROR(IF(FIND(C$1,$A2)>0,1,0),0)
Now of these cells under C2 and on to the right will have a 1 if the keyword matches the heading above that cell, a 0 if not. Then, just sum the columns in row be:
// copy these down
In cell B2: =if(SUM(C2:AD2)>2,1,0)
This column B will now show a 1 beside each course with 3 occurrences or more, a 0 for any with less. Now, just sum this column B for the total number of courses:
=SUM(B:B)
Note, this counts occurrences of a string. Thus a search for "and" would return to in the entry "random and unusual." Just a warning...
Fill the Excel spreadsheet as follows:
Row 1:
A1: Description. Below there will be descriptions of your courses.
B1, C1, ... Z1 (next 25 cells) - Keywords to find in descriptions.
AA1: Sum. Below will be numbers of keywords found in each description.
Column 1:
A2, A3, ... - Course descriptions.
Row 2 - Formulas for course 1:
B2: Insert formula: IF(ISNUMBER(SEACH(B$1;$A2));1;0)
Note $ characters in the formula above: B$1 - fixed column (1)
and $A2 - fixed row. This is required to keep column / row fixed,
as the formula will be copied (description below).
Copy the above formula to cells C2:Z2.
This way you have in each cell either 1 if the keyword above
(in row 1) was found in course name (in column 1).
AA2 (sum column): Insert formula: SUM(B2:Z2). This way in column AA
you have the number of keywords (from row 1) found in
description (in column A).
Copy formulas from A2:AA2 to each following row with description filled.
Assuming that you have 100 such course descriptions, you have
till now filled:
Row 1 with header data.
Rows 2 to 101 with descriptions (column A) and formulas
(further columns).
Then, in cell AA102 (below the last sum) enter formula:
COUNTIF(AA2:AA101;">3") - count cells containing value more than 3.
This is the result you are looking for.
If you have more or less course descriptions, change the above
formula (and its location) accordingly.
And the last remark: I used non-English version of Excel and then
"manually" translated my native function names into English.
So in case of function name errors try to figure out what actual function
name should be.

Search columns and return number of cells containing "5" against colleague name

What I'm looking for is a formula that will do the following: (I'll be using the first row for this example):
Firstly check cells E:J for cells containing a 5.
If all cells contain a 5 it will check the person's name and then add this to the box in column B against the correct name.
If cells E:J have less than 5 in any of these cells it will disregard this row altogether.
To clarify, for Shaun it will count how many rows next to his name have 5's across the board then put the total number of rows fitting this criterion next to his name in Column B.
We can do this with a helper column:
Helper column, keep the name if the count of 5 equals to 5.
Enter below to K2 and fill down.
=IF(COUNTIF(E2:J2,5)=5,D2,"-")
Then we are counting how many times name appears in the helper column. Enter below to B2 and fill down.
=COUNTIF($K$2:$K$11,A2)
Create formula in K2 (output the name if all values are 5)
=IF( AND(E2=5,G2=5,H2=5,I2=5,J2=5), D2, "")
Create the formula at B2which will sum all occurrences of the names
=SUM(IF(K2:K11=A2,1,0))
(and press ctrl+shift+enter)
You maybe will need to replace , with ; (depends on your excel version).

Excel - Find a value in an array and return the contents of the corresponding column

I am trying to find a value within an array and then return the value in a specific row in the corresponding column.
In the example below, I need to know which bay the Chevrolet is in:
Column A Column C Column D Column E
Chevrolet Bay 1 Bay 2 Bay 3
Toyota Ford Saturn
Honda Chevrolet Jaguar
Ferrari Subaru Lexus
Mitsubishi Hundai BMW
I am looking for Chevrolet in the array C2:E5. Once it determines that the Chevrolet is in Column D, I need for it to return the value in D1. If it was in column E, I need it to return the value in E1.
Any help would be greatly appreciated. Thank you so much in advance.
Try this Array Formula:
=INDEX($C$1:$E$5,1,SMALL(IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99),1))
or if you are sure that each column contains exactly what's being searched it can be written like this:
=INDEX($C$1:$E$5,1,SMALL(IF($C$1:$E$5=A1,COLUMN($A:$C),99^99),1))
Enter formula in any cell by pressing Ctrl+Shitf+Enter.
How does it work?
Our ultimate goal is to find the Column that contains the match:
First we did the search for the match using this formula: SEARCH(A1,$C$1:$E$5). It just checks if any of the entries matched A1. Actually, it can be simplified to $C$1:$E$5=A1 but I'm not sure if all entries in each column match exactly what's in A1.
That formula will produce an array of values when entered as array formula. Something like: {SEARCH(A1,C1), SEARCH(A1,D1), SEARCH(A1,E1);... SEARCH(A1,E5)}. The result will be array of number(s) and error (if non was found). But we don't want that, else we will be returning error everytime.
We then use IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99). This formula returns the Column Number if there is a match and a relatively huge number 99^99 otherwise. Result would be: {99^99, 99^99, 99^99, 2, ..., 99^99}.
And we are close to what we need since we already have an array of Column and huge number. We just use SMALL to return the smallest number which in my opinion is the lowest Column Number where a match is found. So SMALL(IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99),1) would return 2. Which is the column where Chevrolet is referenced at $C$1:$E$1.
Since we already have the column number we simply use INDEX Function which is: INDEX($C$1:$E$5,1,2).
Note: 99^99 can be any relatively large number. Not necessarily 99^99. Actual 16385(max column number in Excel 2007 and up + 1) can be used.
Result:
Another quick and dirty answer is to put a "dummy" row above the entire data set and then determine which placeholder column returned the correct result.
In B1, you can put the equation
=MATCH($A$2,B3:B6,0)
And then in C1, you can put
=MATCH($A$2,C3:C6,0)
And so on until you've covered all the rows and columns. Change the B3:B6 & C3:C6 to reflect the actual rows of data in the given column.
Now, the fun array formula which will actually return the bay. I have this array formula in cell A1 and it is looking from B1:D1, but you can move cell A1 anywhere you want and the B1:D1 range should be all the dummy columns you made above. Also, this is assuming that the bays you want are in row 2 (if they are in a different row, change R2C to R#C where # is the row number). In order to properly enter, enter the formula and then press CTRL+SHIFT+ENTER.
=INDIRECT("R2C"&SUM(IF(ISERROR(B1:D1),FALSE,B1:D1))+1,FALSE)
If the formula is entered properly, it will show curly brackets { } around the equation when you single click on the cell.
This formula will do it, assuming that the lookup value is in A1:
="Bay "&SUMPRODUCT((B2:D5=A1)*(COLUMN(B2:D5)))-1
You could easily adjust it to add more rows and columns.
The formula returns the column number that contains the lookup value and concatenates it with the word Bay to return the exact result you want.
The -1 at the end adjusts for the fact that the Bay 2 column is actually the third column in the worksheet, so you might need to adjust that offset as well.
The SUMPRODUCT function is much undervalued. More on it here:
http://fiveminutelessons.com/learn-microsoft-excel/multiply-two-columns-and-add-results-using-sumproduct
The SUMPRODUCT formula above is perfect for what I want.
E.g. to find the location - COLUMN and ROW - of a given value at A1 in a 2D Range A2:J44
use: =SUMPRODUCT((A2:J44=A!)*(COLUMN(A2:J44))) gives the Absolute* COL#
and : =SUMPRODUCT((A2:J44=A1)*(ROW(A2:J44))) gives the Absolute* ROW#
(not where it is in the range)
These can then be used in e.g. INDEX() or CELL() etc functions.

Excel - Find the biggest gap in a set of numbers?

I have a series of numbers
0,1,99,5,5,98,9
They are unsorted and will remain that way.
I cannot use macros.
I want the answer 89 from a formula or an array formula.
89 is the biggest gap (between 9 and 98) in this series when sorted.
I want a formula, no vba, and no sorting my column or row.
I need a formula that sorts the list and subtracts one cell relative to the sorted list and gives the largest difference of the list of differences it creates.
so the list becomes 0,1,5,5,9,98,99
subtracts the current from the previous (na,1,4,0,4,89,1)
and gives me the max 89.
My list is a column of 7 rows.
This formula must be array-entered. In the formula RNG refers to the range where you have entered your numbers, e.g. A1:A7
=MAX(LARGE(RNG,ROW(INDIRECT("1:"&-1+COUNT(RNG))))-
LARGE(RNG,ROW(INDIRECT("2:"&COUNT(RNG)))))
To array-enter a formula, after entering
the formula into the cell or formula bar, hold down
ctrl-shift while hitting enter. If you did this
correctly, Excel will place braces {...} around the formula.
You can see how the formula works by using the Evaluate Formula option on the Formula Auditing tab of the Formulas ribbon.
In brief, the formula works by creating two arrays, sorted in order of size. The "K" value of the LARGE function is an array created by the ROW(INDIRECT sequence. The first returns
{1;2;3;4;5;6}
and the second returns
{2;3;4;5;6;7}
The two arrays of values returned would then be:
{99;98;9;5;5;1}
{98;9;5;5;1;0}
Subtracting one from the other results an array of the differences, and we find the MAX.
MAX(A:A) - LARGE(A:A,2) gives the difference between the largest and second-largest value if your numbers are in column A. Don't put this formula in column A.
Place the values in A1 thru A7 in any order!
In B1 enter:
=RANK(A1,$A$1:$A$7,0)+COUNTIF($A$1:$A1,A1)-1
and copy down thru B7
In C1 enter:
=INDEX($A$1:$A$7,MATCH(ROW(),B$1:B$7,0))
and copy down thru C7
In D2 enter:
=C1-C2
and copy down thru C7
Finally in E1 enter:
=MAX(C:C)
Column B represents the order of the values in column A if they were sorted. Column C contains the values of column A in sorted order. Column D are the differences and E1 gives the desired answer. Here is an example:

Resources