How do I do a MAX over a conditional set of values?

I'm used to interacting with databases so I don't know if a spreadsheet can do this, but…


Suppose I have a table with three columns: Date, Category, Amount. I would like to take all of the rows with the same value for Category (e.g. Entertainment) and find the largest value for Amount amongst those rows. Something like:


=MAX(VALUES('Budget' :: 'Category', 'Entertainment'))


I know that the VALUES function doesn't exist... I'm just trying to give an example. The way VALUES works is that it returns a range of rows for a given range and a given value.

Posted on Sep 29, 2011 7:00 PM

Reply
4 replies

Sep 29, 2011 8:28 PM in response to MrAvery

A function like that might be possible in Excel with Excel's array functions but not so simple to do in Numbers. But, depending on what you are trying to accomplish, here is another idea:


Use the Categorize feature of Numbers to categorize the table by your Category column. Use the category formulas feature, choosing Maximum as the function, to get the maximum amount for each category.


You can't use those maximums in any downstream formulas or in charts, they are for looking at and that's it.


Note that turning on categories will sort the table. If you turn off categories and want it sorted back the way it started, you need a way to do that. Maybe you can sort your table by date, sometimes people add a column for an index number for each record (1,2,3 etc).


If you really need it done with a formula, it will require more than just a formula in a cell. It will require a new column full of formulas for each category you want to do. It is easy but cumbersome. Here is the start of it for three categories:


User uploaded file

The formula in cell E2 (directly below the word "Home") is =IF($B2=E$1,$C2,"") . You fill right and down to the other columns & rows. With the categories separated into columns, you can find the max of each. You can hide these columns after you have everything set up.

Sep 30, 2011 6:54 AM in response to MrAvery

MrAvery wrote:


I'm using Numbers '08. I can't find the categories feature. I looked in the User Manual and in the help. Is this a Numbers '09 feature?

This new function is a two years and a half old one 😉


Yvan KOENIG (VALLAURIS, France) vendredi 30 septembre 2011 15:53:28

iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0

My iDisk is : <http://public.me.com/koenigyvan>

Please : Search for questions similar to your own before submitting them to the community



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I do a MAX over a conditional set of values?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.