Index match formula with duplicate value - excel

I have an excel index/match formula (see below) but my data contains duplicate values therefore excel only returns the first value. Is there a way to modify my formula below to return to the nth value?
=IF(B24>='3. Lookups'!CU:CU, INDEX('3. Lookups'!CZ:CZ, MATCH(AC24, '3. Lookups'!CT:CT,0)), "blank")

Try something like this for the INDEX part. This will return the second value. For the Nth value, adjust the last parameter in the formula.
=INDEX('3. Lookups'!CZ:CZ,SMALL(IF('3. Lookups'!CT:CT=AC24,ROW('3. Lookups'!CT:CT)-ROW(INDEX('3. Lookups'!CT:CT,1,1))+1),2))
It's an array-formula, so use Ctrl + Shift + Enter to confirm,

Try,
=iferror(index('3. Lookups'!CZ:CZ, aggregate(15, 7, row(a:a)/('3. Lookups'!CT$1:CT$9999=AC24), nth)), "blank")
Replace nth with the actual number you want returned.

Related

Lookup excel return min value if no match found

If number from first coulmn is found in the second column, it should return that number.
If number from first coulmn is not found in the secound column, it should return closest possible min value
You can use vlookup() like this, BUT you need to sort the values:
In C1 enter the array formula:
=MAX(IF(B:B<=A1,B:B))
and copy downward:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
NOTE:
Sorting is not required.
Array entry is not required if you are using Excel 365.
Another option is SUMPRODUCT:
=SUMPRODUCT(MAX(--($B$1:$B$12<=A1)*$B$1:$B$12))
It works on Excel 2007 or higher, no need of array entered formula and no need of sorting.

If Vlookup returns Error, then how to Increment the table array

I am trying to do vlookup, but however it is matching only first row and my return value is always at last Column (reason).
=vlookup(H:H,A:F,6,0)
I tried with Match and Index functions, but it's not looking up for values other than first column.
I know the vlookup will not work, but any suggestions?
Try INDEX/AGGREGATE combination:
=INDEX($F$2:$F$6,AGGREGATE(15,6,(1/(H2=$A$2:$E$6))*ROW($F$2:$F$6)-1,1))
Try this shorter formula.
In I2 enter array formula and copied down :
=INDEX(F:F,SUM((IFNA($A$2:$E$6,"")=H2)*ROW($A$2:$E$6)))
This is an array formula and needs to be confirmed by pressing with Ctl + Shift + Enter.

Formula to find the second to last value in row - Excel

I have the formula to find the last value in a row - =LOOKUP(1,1/(3:3>0),3:3) (depending on the row)
but can't seem to get it to return the second to last value/cell in the row.
Please help!
Try,
=INDEX(3:3, AGGREGATE(14, 6, COLUMN(A:XFC)/(A3:XFC3>0), 2))
Awesome.. I edited the formula to:
=INDEX(3:3, AGGREGATE(14, 6, COLUMN(A3:XFC3)/(A3:BL3>0), 2))
Where BL3 is where my current last data value ends. Once I drag, the formula automatically updated the column and row value.
Thanks so much!
For row #3, the array formula:
=INDEX(3:3,IF(COUNTA(3:3)=0,"",MAX((3:3<>"")*(COLUMN(3:3))))-1)
will yield the next-to-last value in that row:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
If you are sure that row #3 will not be empty, then use this array formula instead:
=INDEX(3:3,MAX((3:3<>"")*(COLUMN(3:3)))-1)
To avoid array formulas consider:
=INDEX(3:3,SUMPRODUCT(MAX((COLUMN(3:3))*(3:3<>"")))-1)

How to reverse the order of a match function, from top-bottom to the activecell-top

I currently have the following in cell T124
=MATCH("Sub-Assembly",M1:M124,0)
I would like to search from the active row (124) upwards in a specified column (M) and return the first cell's path that has the value Sub-Assembly within.
Currently, it looks in ascending order from row 1 and returns the first value, I would like it to look upwards from the active row.
Thanks
Try,
=aggregate(14, 6, row($1:$124)/(M$1:M$124="Sub-Assembly"), 1)
You should be able to use this, enter with CTRL+SHIFT+ENTER
=MAX(IF(M1:M124="Sub-Assembly",1,0)*ROW(M1:M124),0)
You can adapt MATCH function for this, e.g.
=MATCH(2,1/(M$1:M$124="Sub-Assembly"))
Confirm with CTRL+SHIFT+ENTER
like MATCH this will return the position within the range, but of last match, not first
You can accomplish this my using an Array Equation
=MAX(IF(M1:M124="Sub-Assembly",ROW(M1:M124)-ROW(INDEX(M1:M124,1,1))+1))
Click in the formula bar after and type ctrl+shift+enter.

Two column lookup in table array using INDEX and MATCH

I would like excel to display the value from table array which has two matching cells com_cd and div_cd using INDEX and MATCH.
I have tried the following formula but it did not work.
=INDEX(K9:K53,MATCH(K3,I9:I53,0),MATCH(K4,J9:J53,0))
Here is a screenshot of the excel sheet with the desired result given according to com_cd and div_cd
Try an array formula (CTRL + SHIFT + ENTER) instead of Enter.
=INDEX(K9:K53,MATCH(K3&K4,I9:I53&J9:J53,0),1)
Not tested but should work.
Will edit later explaining our formula and reason why your formula doesn't work.
Your column_num parameter on the INDEX function cannot sinply provide a secondary row criteria. You need a way to ensure a two column match on the row_num parameter and leave the column_num either blank or as 1 (there is only only column in K9:K53).
The standard formula for K5 should be,
=index(K9:K53, aggregate(15, 6, row(1:45)/((i9:i53=k3)*(j9:j53=k4)), 1))
... or,
=index(K9:K53, min(index(row(1:45)+((i9:i53<>k3)+(j9:j53<>k4))*1e99, , )))
The cell range K9:K53 has a total of 45 rows. The position within K9:K53 will be within ROW(1:45). The first formula forces any non-matching row into an #DIV/0! error state and the AGGREGATE¹ function uses option 6 to ignore errors while retrieving the smallest valid entry with the SMALL sub-function (e.g. 15). The second formula performs the same action by adding 1E+99 (a 1 followed by 99 zeroes) to any non-matching row and taking the smallest matching row with the MIN function.
      
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.

Resources