• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Multiple Criteria Lookup (Using Table Names and Column names (not $A1:C23) to return Array of values

Jcbperault

New Member
I’ve been really struggling with a particular search using multiple criteria on an actual TABLE using Table Names and Column Names. This appears to work differently than when using the A1:B200 notation for some reason.

I need to do it like this in order to accommodate adding of rows and columns without needing to adjust the formulas.

And... to make it even more difficult I need one of the criteria to be within a numeric range.

GOAL - Find all the items that match the following criteria
Type = ON
Material = Aluminum
OD +/- ODTolerance = 23 +/- 0.02
There are 45 of these in the list. I need the result to be a list of Devices that match all this criteria.

I've tried a large number of Index/Match/Countif/Countifs/etc... But cannot get it to work.

Here is the [Ctrl][Shift][Enter] example of one cell

=IFERROR(INDEX(_DLookup[Hex], SMALL(IF(COUNTIF(_DLookup[Hex Type],_HT)*COUNTIF(_DLookup[Material],_HM)*COUNTIFS(_DLookup[OD (mm)],">="&_O-_ODt,_DLookup[OD (mm)],"<="&_O+_ODt), ROW(_DLookup[Device])-MIN(ROW(_DLookup[Device]))+1), ROW(A1)), COLUMN(A1)),"-")

I'm pretty sure that the countifs part in here is messing up the whole thing, but I'm not sure what to do about it.

Any help would be GREAT.
Thanks
 

Attachments

  • Chandoo-Test.xlsx
    224.7 KB · Views: 5
Try,

In G9, enter non-array formula and copied down :

=IFERROR(INDEX(_DLookup[Hex],AGGREGATE(15,6,ROW(_DLookup[Device])-MIN(ROW(_DLookup[Device]))+1/(_DLookup[Hex Type]=_HT)/(_DLookup[Material]=_HM)/((_O+_ODt)>=_DLookup[OD (mm)])/((_O-_ODt)<=_DLookup[OD (mm)]),ROWS($1:1))),"-")

or,

Array formula (SHIFT+CTRL+ENTER)

=IFERROR(INDEX(_DLookup[Hex],SMALL(IF((_DLookup[Hex Type]=_HT)*(_DLookup[Material]=_HM)*((_O+_ODt)>=_DLookup[OD (mm)])*((_O-_ODt)<=_DLookup[OD (mm)]),ROW(_DLookup[Device])-MIN(ROW(_DLookup[Device]))+1),ROWS($1:1))),"-")

Regards
Bosco
 

Attachments

  • Chandoo-Test (2).xlsx
    212.8 KB · Views: 7
Last edited:
Bosco, that is perfect! Thanks. I hope this helps others. There are MANY, MANY Excel tips out there on how to use arrays and how to search with multiple criteria, but I have never seen one that uses table names and column names to do it.

Thanks again.
-Joe
 
Joe

Using structured references is not so different from using named ranges. In fact if the structured references are so long that they obscure your formula you can apply names to them such as

upload_2017-11-8_23-20-39.png
upload_2017-11-8_23-19-51.png

These resize with the table. I develop array formulas on the worksheet such as
= IF( (§HexType=_HT) * (§Material=_HM) * (§OD>=_O-_ODt) * (§OD<=_O+_ODt), k )
but, once it is working, transfer it to a named formula (here called 'matches').
The record index array 'k' is given by
upload_2017-11-8_23-25-56.png

Having bitten the bullet and accepted setup costs, the final worksheet formula is a reasonably readable
= INDEX( §Hex, SMALL( matches, k ) )

If you do not like ending with NUM! errors it is always possible to count the number of matches and modify the formula to read
=IF( k<COUNT(matches), INDEX( §Hex, SMALL( matches, k ) ), "" )

In essence, there is no difference between this solution and that proposed by Bosco but I like to use named formulas (they are always evaluated as arrays) to simplify the final formula by breaking it into a sequence of more readable steps.

Peter
 

Attachments

  • upload_2017-11-8_23-18-48.png
    upload_2017-11-8_23-18-48.png
    4 KB · Views: 4
Back
Top