SOLVED

INDEX MATCH function, avoid duplicate returns

%3CLINGO-SUB%20id%3D%22lingo-sub-1188587%22%20slang%3D%22en-US%22%3EINDEX%20MATCH%20function%2C%20avoid%20duplicate%20returns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1188587%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20everyone!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20working%20on%20a%20sheet%20for%20work.%20I%20am%20on%20my%20last%20task%20and%20can't%20seem%20to%20figure%20this%20one%20out.%20I'm%20hoping%20someone%20can%20help%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20data%20sheet%20with%20all%20the%20data.%20In%20my%20current%20sheet%20I%20would%20like%20it%20to%20return%20a%20list%20of%20all%20the%20names%20matching%20these%20two%20criteria.%20My%20formula%20is%20as%20follows%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DINDEX('Horse%20data'!B2%3AB100%2C%20MATCH(1%2C%20(%24I%2413%3D'Horse%20data'!C2%3AC100)%20*%20(%24K%2413%3D'Horse%20data'!D2%3AD100)%2C%200))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20I%20have%20with%20it%20is%20that%20it%20returns%20duplicates%2C%20because%20for%202%20or%203%20cells%2C%20the%20first%20best%20match%20is%20the%20same%2C%20until%20my%20search%20area%20has%20moved%20down%20enough%20to%20continue%20on%20to%20the%20next%20match.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20any%20way%20to%20rewrite%20this%20formula%20to%20return%20a%20list%20of%20'unique%20distinct%20values'%20and%20avoid%20duplicate%20returns%3F%3C%2FP%3E%3CP%3EPreferably%20without%20adding%20more%20columns%2C%20but%20if%20there's%20no%20other%20way%20I'd%20accept%20any%20solution!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1188587%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1188603%22%20slang%3D%22en-US%22%3ERe%3A%20INDEX%20MATCH%20function%2C%20avoid%20duplicate%20returns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1188603%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F565648%22%20target%3D%22_blank%22%3E%40certavi%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20on%20Excel%20with%20dynamic%20arrays%20that%20could%20be%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DUNIQUE(FILTER('Horse%20data'!B2%3AB100%2C%0A%20%20(I%2413%3D'Horse%20data'!C2%3AC100)%20*%20(%24K%2413%3D'Horse%20data'!D2%3AD100)%0A))%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1188632%22%20slang%3D%22en-US%22%3ERe%3A%20INDEX%20MATCH%20function%2C%20avoid%20duplicate%20returns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1188632%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BYes%2C%20that%20works%20great!%20Thanks%20a%20lot!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1188646%22%20slang%3D%22en-US%22%3ERe%3A%20INDEX%20MATCH%20function%2C%20avoid%20duplicate%20returns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1188646%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F565648%22%20target%3D%22_blank%22%3E%40certavi%3C%2FA%3E%26nbsp%3B%2C%20you%20are%20welcome%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi everyone!

 

I'm working on a sheet for work. I am on my last task and can't seem to figure this one out. I'm hoping someone can help:

 

I have a data sheet with all the data. In my current sheet I would like it to return a list of all the names matching these two criteria. My formula is as follows:

 

=INDEX('Horse data'!B2:B100, MATCH(1, ($I$13='Horse data'!C2:C100) * ($K$13='Horse data'!D2:D100), 0))

 

The problem I have with it is that it returns duplicates, because for 2 or 3 cells, the first best match is the same, until my search area has moved down enough to continue on to the next match.

 

Is there any way to rewrite this formula to return a list of 'unique distinct values' and avoid duplicate returns?

Preferably without adding more columns, but if there's no other way I'd accept any solution!

28 Replies
best response confirmed by certavi (New Contributor)
Solution

@certavi 

If you are on Excel with dynamic arrays that could be

=UNIQUE(FILTER('Horse data'!B2:B100,
  (I$13='Horse data'!C2:C100) * ($K$13='Horse data'!D2:D100)
))

@Sergei Baklan Yes, that works great! Thanks a lot!

@certavi , you are welcome

Hello, is there a way to tdo this in excel 2007 version? @Sergei Baklan 

The problem gets complicated in Excel 2007. To simplify it, I used an auxiliary column, and array-entered the following formula in cell L2, then copy it down. The formula returns the values from column B that satisfy the two criteria.

=IFERROR(INDEX('Horse data'!B$2:B$100,SMALL(IF(($I$13='Horse data'!C$2:C$100) * ($K$13='Horse data'!D$2:D$100),ROW('Horse data'!B$2:B$100)-ROW('Horse data'!B$2)+1,""),ROWS(L$2:L2))),"")

  The next step is to avoid duplicate returns. I did that by copying down another array-entered formula in column M:

=IFERROR(INDEX(L$2:L$100,SMALL(IF(IFERROR(MATCH(L$2:L$100,L$2:L$100,0),0)*(L$2:L$100<>"")=ROW(L$2:L$100)-ROW(L$2)+1,ROW(L$2:L$100)-ROW(L$2)+1,""),ROWS(M$2:M2))),"")

 

@Sergei Baklan  im having a similar issue with an excel formula. When I drag this down, I am having duplicate returns until I another value hit. Do you know how the formula should look to delete the duplicates?

 

=INDEX('Walleye OMS'!B2:B303,MATCH('final (2)'!A3,'Walleye OMS'!U2:U303,0))

 

cweaver345414_0-1651433440882.png

 

 

@cweaver345414,

MATCH always returns the first match for the item sought. That's why it keeps duplicating the value returned.

 

I assume that you are copying the formula down in worksheet final (2) starting in row 3.

 

=INDEX('Walleye OMS'!B$2:B$303,AGGREGATE(15,6,(ROW('Walleye OMS'!U$2:U$303)-ROW('Walleye OMS'!U$2)+1)/('Walleye OMS'!U$2:U$303='final (2)'!A3),COUNTIF('final (2)'!A$3:A3,'final (2)'!A3)))

 

Brad

@Brad Yundt wow that worked thank you so much!!

@cweaver345414 @Brad Yundt 

 

Hi Brad, it looks like im running into a similar issue but on a different spreadsheet. im trying to grab all equity quantities and put it on a separate spreadsheet. Do you by chance have any idea what I may be missing?

 

=INDEX('Walleye JPMcopy)'!L$2:L$643,AGGREGATE(15,6,(ROW('Walleye JPMcopy)'!D$2:D$643)-ROW('Walleye JPMcopy)'!D$3)+1)/('Walleye JPMcopy)'!D$2:D$643="EQUITIES"),COUNT('Walleye JPMcopy)'!D$3:D3,'Walleye JPMcopy)'!D3)))

 

cweaver345414_0-1651445730746.png

 

 

@cweaver345414,

It would be helpful to see your actual workbook and know exactly where you want to put the formula.

 

I assumed that you are retrieving data from worksheet Walleye JPMcopy) column L, and are looking to return only those values that pertain to EQUITIES. I also assumed that your data start on row 2, and that the formula is also placed on row 2, possibly on a different worksheet. If so, you might try copying down:

=IFERROR(INDEX('Walleye JPMcopy)'!L$2:L$643,AGGREGATE(15,6,(ROW('Walleye JPMcopy)'!D$2:D$643)-ROW('Walleye JPMcopy)'!D$2)+1)/('Walleye JPMcopy)'!D$2:D$643="EQUITIES"),ROWS(D$2:D2))),"")

The suggested formula returns an empty string (looks like a blank) when there are no more EQUITIES.

 

If I guessed incorrectly, please post a sample workbook and tell me exactly which cell needs the formula. 

@Brad Yundt 

Hi Brad,

Thank you for the input. I am trying to copy the data into cell G3 in spreadsheet Final (2) from sheet Walleye JPMcopy). I put "EQUITIES" because I was unsure where to select. Please let me know if you need more information.

cweaver345414_0-1651449748906.png

 

I want to see a copy of the actual workbook along with a small selection of the results you want to return. When looking at the formula you were trying to use, I couldn't tell where the formula was being placed. Nor could I tell what the exact name of the worksheet might be--I now see that worksheet final (2) has a closing right parenthesis, something that was missing in your original formula.

It is also not clear whether I'm supposed to return information on all the EQUITIES, or all the info that is available in worksheet Walleye JPMcopy.

When I look at your workbook, all care about is worksheets final (2), Walleye JPMcopy and whichever worksheet will be containing the formula. Similarly, all I care about on worksheet Walleye JPMcopy are columns D and L, and column L could have the numbers 1 through xx as their data. I don't need a lot of data--I used ten rows in my test workbook.

What is important is the layout. Where does the data start and end? Where does the formula go? What values do you expect the formula to return? Is the formula only supposed to return EQUITIES? Should it return other types of investments, too?

@cweaver345414,

This is my test workbook. Feel free to mark it up so I know what the formula is supposed to be doing.

 

Brad

 

 

@Brad Yundt im not able to attach my spreadsheet for some reason but hopefully these screenshots help. I am just trying to pull all quantities (equities) from Walleye sheet in to final sheet.

 

 

 

cweaver345414_0-1651505723378.png

cweaver345414_1-1651505732238.png

 

 

Have you tried the last formula I suggested? It should be working for the problem you show in the screenshots once you correct the names of the worksheets.
=IFERROR(INDEX('Walleye JPMcopy)'!L$2:L$643,AGGREGATE(15,6,(ROW('Walleye JPMcopy)'!D$2:D$643)-ROW('Walleye JPMcopy)'!D$2)+1)/('Walleye JPMcopy)'!D$2:D$643="EQUITIES"),ROWS(D$2:D2))),"")

Yeah but it looks like it isnt pulling anything from Walleye JPMCopy) sheet.@Brad Yundt 

cweaver345414_0-1651513813330.pngcweaver345414_1-1651513829948.png

 

Please disregard! I did a Vlookup and that seemed to work!

@cweaver345414,

"I did a Vlookup and that seemed to work!"


That's why you should post a sample workbook in the thread, or a link to one in your OneDrive. You probably would have gotten the right answer the first time.

Glad you got things sorted out.

 

Brad

 

 

@Brad Yundt@cweaver345414 it looks like i am running into a small issue with another formula. im trying to get all option quantities in the JPM Quantity tab, would you know what formula to use?

 

 

cweaver345414_0-1651605437054.png

cweaver345414_1-1651605525450.pngcweaver345414_2-1651605572529.png