Index/Match/Maxifs Question

Marter

New Member
Joined
Jul 3, 2021
Messages
6
Hello,

I'll explain what I'm trying to do then tell you what I'm currently doing that isn't working as I want it to.

What I'm trying to do. I want a formula to return text from Column A based on the highest number in Column B, but only in cells that match Column C.

I've attached a photo.

Essentially I only want the highest result for each quarter.

In the example I listed above, this works for Q4 and Q3 but not for Q2 and Q1. The photo has the formula for Q2 but I'll post it here as well:

=INDEX(A:A,MATCH(MAXIFS(B:B,C:C,"Q2"),B:B,0))

The formulas are all the same, just the "Q#" is changed.

What it's doing is searching based on the criteria but then giving me the first result with criteria ignored. So for Q2 it sees that "Strawberries" with an 8 is the highest, but then it spits out "Peaches" as that's the first 8 in the column, even though I told it only ones that match Q2.

Please let me know what I'm doing wrong and what I can do to achieve what I need.

Thanks!
 

Attachments

  • Clipboard 1.jpg
    Clipboard 1.jpg
    62.4 KB · Views: 26

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try...

Pasta1
ABCDE
1TypeRatingQuarter
2Apples7Q4
3Pears6Q4
4Peaches8Q4
5Oranges9Q3
6Blueberries1Q3
7Watermellon6Q3Q4Peaches
8Strawberries8Q2Q3Oranges
9Raspberries4Q2Q2Strawberries
10Bread3Q2Q1Steak
11Cheese5Q1
12Steak7Q1
13Plum3Q1
14Pizza1Q1
Plan4
Cell Formulas
RangeFormula
E7:E10E7=INDEX(A$2:A$14,AGGREGATE(15,6,(ROW(A$2:A$14)-ROW(A$2)+1)/((C$2:C$14=D7)*(B$2:B$14=AGGREGATE(14,6,B$2:B$14/(C$2:C$14=D7),1))),1))


Hope this helps

M.
 
Upvote 0
Solution
How would I reverse this to look for lowest instead of highest?

Try
Pasta1
ABCDEFG
1TypeRatingQuarter
2Apples7Q4
3Pears6Q4
4Peaches8Q4
5Oranges9Q3
6Blueberries1Q3HighestLowest
7Watermellon6Q3Q4PeachesPears
8Strawberries8Q2Q3OrangesBlueberries
9Raspberries4Q2Q2StrawberriesBread
10Bread3Q2Q1SteakPizza
11Cheese5Q1
12Steak7Q1
13Plum3Q1
14Pizza1Q1
Plan4
Cell Formulas
RangeFormula
E7:E10E7=INDEX(A$2:A$14,AGGREGATE(15,6,(ROW(A$2:A$14)-ROW(A$2)+1)/((C$2:C$14=D7)*(B$2:B$14=AGGREGATE(14,6,B$2:B$14/(C$2:C$14=D7),1))),1))
G7:G10G7=INDEX(A$2:A$14,AGGREGATE(15,6,(ROW(A$2:A$14)-ROW(A$2)+1)/((C$2:C$14=D7)*(B$2:B$14=AGGREGATE(15,6,B$2:B$14/(C$2:C$14=D7),1))),1))


Note that the only difference between the formulas is in the second AGGREGATE function: to get the Largest I used 14 as the first parameter; to get the Smallest one, I used 15 as the first parameter.

Take a look at Help about the AGGREGATE function

M.
 
Upvote 0
Note that the only difference between the formulas is in the second AGGREGATE function: to get the Largest I used 14 as the first parameter; to get the Smallest one, I used 15 as the first parameter.

Take a look at Help about the AGGREGATE function

M.

I had tried that because I figured it was something like that and it kind of worked ... but it counts blank cells as the lowest. Is there a way it can only target filled cells?
 
Upvote 0
I had tried that because I figured it was something like that and it kind of worked ... but it counts blank cells as the lowest. Is there a way it can only target filled cells?

Could you provide an example with blank cells you're getting wrong results?

M
 
Upvote 0
Could you provide an example with blank cells you're getting wrong results?

M
Sure thing! I tried using the Mini-sheet but it wouldn't work, sorry. Have to do with pictures and written formulas.

In the picture, all of the blanks have taken precedence over the actual lowest numbers. The formulas are:

=INDEX(A$2:A$14,AGGREGATE(15,6,(ROW(A$2:A$14)-ROW(A$2)+1)/((C$2:C$14=D7)*(B$2:B$14=AGGREGATE(15,6,B$2:B$14/(C$2:C$14=D7),1))),1))

=INDEX(A$2:A$14,AGGREGATE(15,6,(ROW(A$2:A$14)-ROW(A$2)+1)/((C$2:C$14=D8)*(B$2:B$14=AGGREGATE(15,6,B$2:B$14/(C$2:C$14=D8),1))),1))

=INDEX(A$2:A$14,AGGREGATE(15,6,(ROW(A$2:A$14)-ROW(A$2)+1)/((C$2:C$14=D9)*(B$2:B$14=AGGREGATE(15,6,B$2:B$14/(C$2:C$14=D9),1))),1))

=INDEX(A$2:A$14,AGGREGATE(15,6,(ROW(A$2:A$14)-ROW(A$2)+1)/((C$2:C$14=D10)*(B$2:B$14=AGGREGATE(15,6,B$2:B$14/(C$2:C$14=D10),1))),1))

So like for Q4 if I put in a 7 for Apples it correctly adjust so that Peaches is the lowest. But when it's blank, that's what it uses.

Hope that makes sense!
 

Attachments

  • Clipboard 1.jpg
    Clipboard 1.jpg
    116.2 KB · Views: 9
Upvote 0
Try

Pasta1
ABCDEFG
1TypeRatingQuarter
2ApplesQ4
3Pears6Q4
4Peaches8Q4
5Oranges9Q3
6BlueberriesQ3HighestLowest
7Watermellon6Q3Q4PeachesPears
8Strawberries8Q2Q3OrangesWatermellon
9RaspberriesQ2Q2StrawberriesBread
10Bread3Q2Q1SteakPizza
11Cheese5Q1
12Steak7Q1
13PlumQ1
14Pizza1Q1
15
Plan2
Cell Formulas
RangeFormula
E7:E10E7=INDEX(A$2:A$14,AGGREGATE(15,6,(ROW(A$2:A$14)-ROW(A$2)+1)/((C$2:C$14=D7)*(B$2:B$14=AGGREGATE(14,6,B$2:B$14/(C$2:C$14=D7),1))),1))
G7:G10G7=INDEX(A$2:A$14,AGGREGATE(15,6,(ROW(A$2:A$14)-ROW(A$2)+1)/((C$2:C$14=D7)*(B$2:B$14=AGGREGATE(15,6,B$2:B$14/(ISNUMBER(B$2:B$14)*(C$2:C$14=D7)),1))),1))


M.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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