Index max formula with multiple criteria

kgardner

New Member
Joined
Sep 3, 2015
Messages
22
I am comparing 2 sets of account balances and want to find the account with the largest change in balance from day to day for a specific product category (Personal Accounts) and location (10). The accounts are separated into groups by a product code and location ID. Below is a data sample.

Sample Balance Data
Account #ProductLocationDay 1 BalanceDay 2 BalanceChange
1234510101000.001500.00500.00
67890301050.00300.00250.00
4455820101000.00900.00(100.00)
7913510201000.002000.001000.00

<tbody>
</tbody>

Criteria
Product nameProduct CodesLocation ID
Personal Accounts1010
Personal Accounts2010

<tbody>
</tbody>

The answer should return 500.00 for location 10 and 1000.00 for location 20. I have tried the formula:

Code:
{=index(account #,max(if((location = location id)*(product = product codes), row(change)))}

and some other combinations of this formula, but it fails to recognize the list of possible product codes in the criteria table. If I set the formula for just one product code such as ...product = "10".. then it returns a value, but not if I try to use the "product codes" list.

Any ideas on what I can do? How can I make sure to include negative changes as well?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I've been pondering how I phrased my question and this may be simpler to understand.

How do I make the following formula work?
Code:
{=MAX(IF(C:C = G1, IF(B:B = H1:H5, F:F)))}

Currently it only works as:
Code:
{=MAX(IF(C:C = G1, IF(B:B = H1, F:F)))}

Where:
B:B = product codes
C:C = location codes
F:F = change in account value
G1 = location ID I'm searching for
H1:H5 = product codes associated with the product group I am searching for

I want to show the largest change in the product group (i.e. Fruit or Meat) based on the associated product codes (i.e. apples, oranges, strawberries or Pork, Chicken, Beef).
 
Upvote 0
Control+shift+enter, not just enter:

=MAX(IF($C$2:$C$400=G1,IF(ISNUMBER(MATCH($B$2:$B$400,H1:H5,0)),$F$2:$F$400)))
 
Upvote 0
Just as I was about to post sample data, a solution appears! Thank you Aladin! How does the ISNUMBER() function work in this formula?
 
Upvote 0
Just as I was about to post sample data, a solution appears! Thank you Aladin! How does the ISNUMBER() function work in this formula?

You are welcome.

MATCH is capable of matching a range against (a) itself or (b) against another range. In the 2nd case you might expect #N/A's to occur among some integers indicating successful matches. Testing these results whether they are numbers using ISNUMBER delivers TRUE/FALSE evaluations. The surrounding IF maps the TRUE values into the F-values which are then evaluated by MAX for an ultimate result.
 
Upvote 0

Forum statistics

Threads
1,216,080
Messages
6,128,692
Members
449,464
Latest member
againofsoul

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