Return Value based on multiple criteria

twilson4

New Member
Joined
Jul 27, 2015
Messages
11
Office Version
  1. 365
Platform
  1. Windows
I am looking to return a value from a fixed column based on certain criteria being met. I have successfully done this using an Index Match formula but to get it to return the value from the correct month I have to hard code the rank value to a specific column and therefor it is not dynamic if/when I change the month.

Criteria 1: Look for a fixed value in a fixed column. (IE Look for "FL" in Column A:A)
Criteria 2: :
First determine which Column is being referenced based on referencing a value (IE 12 Columns Jan-Dec and need to reference the data in column "Feb")
Second, in that column look for a specific value (IE: 1)

Where "FL" and "1" line up, determine that row # and return it from a separate column B:B


Top Accounts by Month-State - 2022.xlsx
D
6ALBERTSONS WAREHOUSE
Southeast
Cell Formulas
RangeFormula
D6D6=IFERROR(INDEX(Data!$B:$B,MATCH(1,(Southeast!$B6=Data!$A:$A)*(Southeast!$C6=Data!$AY:$AY),0)),)
Named Ranges
NameRefers ToCells
Data!_FilterDatabase=Data!$A$2:$BV$758D6
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I can't tell from your post where the different values are found in your sheet. If you want to do a two-way lookup and you know that there will only be one match on the row headings and one match on the column headings, you can do something like this:
MrExcel_20220728.xlsx
ABCDEFGHIJKLMNOPQ
1JanFebMarAprMayJunJulAugSepOctNovDecin colin rowresult
2GA141882587449751466404325FebFL35
3NC515365306350651425538924
4SC454387866722412151688167
5FL873514384862529238588953
6VA836914706871783758838415
Sheet3
Cell Formulas
RangeFormula
Q2Q2=INDEX($B$2:$M$6,MATCH(P2,$A$2:$A$6,0),MATCH(O2,$B$1:$M$1,0))
 
Upvote 0
Kirk - thanks for your reply.

I created a mock up version of my data to see if it would be easier to get into the forum. I think, in reality, I am trying to do a 3 way look up. I am doing it right now in a two way look up but every time I want to look up the rank in a different month I need to manually change the month column I am referencing. Hoping there is a way to reference the rank values in more of an array so I can use one formula and it can then be dynamic depending on the month I am referencing.



Book12
BCDEFGHIJKLMNOPQRS
1StateAZTHIS YEAR RANK
2MonthFebDist. STATEChainsJan RankFeb RankMar RankApr RankMay RankJun RankJul RankAug RankSep RankOct RankNov RankDec Rank
3RankAZCIRCLE K WAREHOUSE111265111111
41CIRCLE K WAREHOUSEAZWALGREENS2228101191122222
52SAFEWAYAZBEVMO!34511971033333
63FRYS MARKETPLACEAZTOTAL WINE & MORE432423544444
74FRYS MARKETPLACEAZFRYS FOOD & DRUG STORE596913141355555
85WHOLE FOODS MARKETAZFRYS MARKETPLACE67787111466666
9AZTRADER JOES753656677777
10AZINDEPENDENTS8222544788888
11AZSAFEWAY964111299999
12AZALBERTSONS1010933231010101010
13AZWHOLE FOODS MARKET1181078881111111111
14AZAAFES121211131515151212121212
15AZDELAWARE NORTH PARKS & RESORTS131112141412121313131313
16AZWALMART DISTRIBUTION CENTER141313151616161414141414
17AZSAMS CLUB151414161717171515151515
18AZDOUBLETREE HOTEL161515121213181616161616
19AZGOBOOZE17161617181891717171717
20AZDEL SOL MARKET181717181910191818181818
21AZBEVERAGE HOUSE191818192019201919191919
22AZWESTIN HOTELS & RESORTS201919201020212020202020
23AZHILTON GARDEN INN212020212121222121212121
24AZGOPUFF22212122222242222222222
25COINDEPENDENTS111111111111
26COTOTAL WINE & MORE223322222222
27CORIO GRANDE MEXICAN RESTAURANT334445433333
28CORIDLEYS445554544444
29COKING SOOPERS552233355555
30COSAMS CLUB666666666666
Sheet1
Cell Formulas
RangeFormula
C4:C8C4=INDEX(G3:G30,MATCH(1,($F$3:$F$30=$C$1)*($I$3:$I$30=$B4),0))
 
Upvote 0
Oh...I see. Since you are matching rank values, are there instances where you might have ties (say 2 chains tied for 3rd place)? Would you want both of them returned? What version of Excel are you using (update account details so that it displays with your name)...there may be an easier way to do this if you have Excel 365.
 
Upvote 0
Oh...I see. Since you are matching rank values, are there instances where you might have ties (say 2 chains tied for 3rd place)? Would you want both of them returned? What version of Excel are you using (update account details so that it displays with your name)...there may be an easier way to do this if you have Excel 365.
I have Office 365.

The issue of returning duplicate Ranks was the first issue I had to resolve earlier today. Using the below formula I was able to generate a rank and ensure there is a single value for each rank by state.

=COUNTIFS($A:$A,$A4,BR:BR,">"&BR4)+COUNTIFS($A$4:$A4,$A4,BR$4:BR4,"="&BR4)
 
Upvote 0
Try this:
MrExcel_20220728.xlsx
BCFGHIJKLMNOPQRS
1StateAZTHIS YEAR RANK
2MonthAprDist. STATEChainsJan RankFeb RankMar RankApr RankMay RankJun RankJul RankAug RankSep RankOct RankNov RankDec Rank
3RankAZCIRCLE K WAREHOUSE111265111111
41SAFEWAYAZWALGREENS2228101191122222
52CIRCLE K WAREHOUSEAZBEVMO!34511971033333
63ALBERTSONSAZTOTAL WINE & MORE432423544444
74TOTAL WINE & MOREAZFRYS FOOD & DRUG STORE596913141355555
85INDEPENDENTSAZFRYS MARKETPLACE67787111466666
9AZTRADER JOES753656677777
10AZINDEPENDENTS8222544788888
11AZSAFEWAY964111299999
12AZALBERTSONS1010933231010101010
13AZWHOLE FOODS MARKET1181078881111111111
14AZAAFES121211131515151212121212
15AZDELAWARE NORTH PARKS & RESORTS131112141412121313131313
16AZWALMART DISTRIBUTION CENTER141313151616161414141414
17AZSAMS CLUB151414161717171515151515
18AZDOUBLETREE HOTEL161515121213181616161616
19AZGOBOOZE17161617181891717171717
20AZDEL SOL MARKET181717181910191818181818
21AZBEVERAGE HOUSE191818192019201919191919
22AZWESTIN HOTELS & RESORTS201919201020212020202020
23AZHILTON GARDEN INN212020212121222121212121
24AZGOPUFF22212122222242222222222
25COINDEPENDENTS111111111111
26COTOTAL WINE & MORE223322222222
27CORIO GRANDE MEXICAN RESTAURANT334445433333
28CORIDLEYS445554544444
29COKING SOOPERS552233355555
30COSAMS CLUB666666666666
Sheet5
Cell Formulas
RangeFormula
B4:B8B4=INDEX(SORT(FILTER($F$3:$S$30,$F$3:$F$30=$C$1),MATCH($C$2,LEFT($F$2:$S$2,3),0)),ROWS($B$4:$B4),MATCH($C$2,LEFT($F$2:$S$2,3),0))
C4:C8C4=INDEX(SORT(FILTER($F$3:$S$30,$F$3:$F$30=$C$1),MATCH($C$2,LEFT($F$2:$S$2,3),0)),ROWS($B$4:$B4),2)
 
Upvote 0
Solution
That worked....took a minute to get it transferred correctly to my actual working file...but got there. Thank you!!
 
Upvote 0
That's great...glad to hear you got it working! I should have mentioned...by using the SORT function, if there are ties--hence multiple rows with the same rank--these formulas will return the top 5 rank values and the associated chain names. So rather than 1,2,3,4,5 you might get 1,2,3,4,4. You might investigate this to see if your approach for assigning different ranks to ties is necessary--you may want to leave the ties and then show them in the summary table.
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top