Multiple Criteria for INDEX/MATCH or VLOOKUP?

Hello,
I have been defeated while trying to reference another sheet and pull information that matches multiple criteria. I need to pull an Account Number that matches both a Vendor Name and Location Name. Essentially, I want to populate the account numbers for specific locations based on a particular vendor. I cannot add a "Helper Column" to the original sheet that I am referencing. Is there a way to accomplish this using either a VLOOKUP or INDEX/MATCH formula? Any help would be greatly appreciated.
Thanks!
Best Answer
-
Hmm... It almost sounds like a bug. How about this...
Delete the formula entirely. Log out. Clear your browser's cookies and cache. Log back in. Re-enter the formula.
Answers
-
try using the collect formula
=index(collect(return RANGE, criteria RANGE 1, criteria 1, criteria RANGE 2, criteria 2),1)
-
@L@123 I have tried the combination of INDEX and COLLECT and cannot for the life of me understand what I am doing wrong.
Here is the formula I have currently:
=INDEX(COLLECT({Full Range}, {Clinic Name}, Clinic@row, {Vendor Zoetis}, "Zoetis"), 1)
But it returns a #INCORRECT ARGUMENT SET error.
-
Posting in hopes that someone may be able to help!
-
Ok, the syntax is correct for your formula, but there could potentially be an issue with the ranges. Make sure to double check all of your ranges have the same number of cells (smartsheet sometimes has a glitch where it deletes ranges as you save them, after you've made them they are fine, but it is good to double check)
If you are interested in how the formula functions, there is an explanation below.
So the collect formula returns a set of values based on a criteria (or a 1d array if you know any coding languages). Basically you treat the collect formula as a range for other formulas. The first part of the collect formula is the return, or the values you want inside of your range. Next is the range you want to filter, and after that is the criteria.
example:
colA colB
A 1
B 1
C 2
A 2
B 3
C 3
=join(collect(colA1:colA6,colB1:colB6,@cell = 2
In the formula above, I use join to show the contents of the collect. The return for this formula will be CA. This is because I am returning (first criteria for collect formula) the values of colA where colB (second criteria for collect formula) is equal to 2 (Third criteria for collect formula). If you have more criteria you want to filter by, you can justt keep adding ranges and criteria to the end of the collect formula, as you did in your own formula for a 2 criteria problem. Another example:
=join(collect(colB1:colB6,colA1:colA6,@cell = "A"
This formula will return the values in colB where colA is equal to "A"
The collect formula is one of the most versatile formulas inside smartsheet, but it needs help from another formula in order to work. Above I have used the join, but you can also use COUNT, SUM, INDEX,SUBSTITUTE, and many other formulas. In your example INDEX is used to return the first value out of the collect formula. Join potentially could work just as well.
-
I agree with @L@123. I believe it may be an issue with the range sizes.
This Range: {Full Range}
Should only be the column you are trying to pull from and not include the other columns/ranges referenced.
-
@Paul Newcome I corrected the range name in my sheet earlier because I realized it could be confusing to someone else, it only references a column with the account numbers in it. I will double and triple check the range sizes, but they should all be the same.
-
When you select the ranges, are you clicking on the column header to select the entire column?
Is that error present in the source data?
-
@Paul Newcome Yes. I wouldn't consider myself a new user, I've McGyvered some long and complex functions in the past. I'm really not sure what is causing this one to fail.
Could it be that there are parent rows in the source sheet? Just exploring all possibilities at this point.
Thanks for trying to help me iron this out!
-
Hierarchy shouldn't affect this particular formula. Did you check the source data to see if that error was present anywhere and is pulling through?
-
How large is the source sheet? I've found collect can get a bit wonky when you get into the 15k row range and use other sheet references in it and can throw some errors before the program catches up.
-
@Paul Newcome The only error on the source sheet is a #NO MATCH error in a column that is not being referenced.
@L@123 The source sheet is 2400 Rows and 16 columns
-
Are all ranges referencing the same sheet?
-
@Paul Newcome Yes. There are only two sheets in play here. A source sheet that the ranges are referencing and a sheet where the formula is being used.
-
Hmm... It almost sounds like a bug. How about this...
Delete the formula entirely. Log out. Clear your browser's cookies and cache. Log back in. Re-enter the formula.
-
So this formula is working now:
=INDEX(COLLECT({Account Number}, {Clinic Name}, Clinic@row, {Vendor Zoetis}, "Zoetis"), 1)
There's still a few hiccups but I'm going to double check, as I think it may just be a typo on our end.
Thank you both so much! I think ultimately it was just a bug.
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 66.7K Get Help
- 438 Global Discussions
- 152 Industry Talk
- 497 Announcements
- 5.3K Ideas & Feature Requests
- 85 Brandfolder
- 155 Just for fun
- 77 Community Job Board
- 509 Show & Tell
- 34 Member Spotlight
- 2 SmartStories
- 307 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!