Subtotal filtered columns

I have read several posts on this issue and none do what I want.


Say I have 4 columns and 7 rows. I want to filter Column 3 on a criteria. When I filter I now have 3 rows instead of 7 displayed ( Not necessarily starting at Row 2 but maybe Row 4 if that is where the first data is from that filter). I want to total only the values of Column 4 that match the filter in Column 2 (which may change next time I filter).


Unflitered Table Example

RowNameSexAge

1

JohnM12
2SidM25
3AndyM17
4BettyF63
5SusanF48
6AshleyF39
7MikeM15

I want the total ages of the women so the filtered table looks like this

RowNameSexAge
4

Betty

F63
5SusanF48
6AshleyF39

So the answer should be 150. And if I filter on Males the table would look like this

RowNameSexAge
1JohnM12
2SidM25
3AndyM17
7MikeM15

And the answer should be 69

Airport Extreme 802.11ac

Posted on Apr 8, 2018 8:24 PM

Reply
31 replies

Apr 9, 2018 8:09 AM in response to Yellowbox

Hi Kevin,


Or, we could do without Pop-Up Menus and create summary tables for each category. Cells in column A of the summary tables are formatted as Automatic.


Adding Fred and Susan to the Database (one more female, one more male, both with black hair)

User uploaded file

Regards,

Ian.


Edit: I received your latest email notification from Apple Support Communities.

Thanks again. You were very helpful. Numbers just seems to pale in comparison to Excel. But I am hoping that it is learning curve on my part.

We are all learning!


Thanks for this challenge.


Happy Numbering,

Ian.

Apr 10, 2018 8:30 AM in response to kevinfromherndon

I think I know what you mean about memory.🙂


This is a neat little trick that Badunit has pointed out. Filter, select the visible cells, drag the sum below into a cell. A formula summing the visible cells is automatically generated, so when you "unfilter" the table the formula still works. In some situations quicker and easier than setting up a SUMIF or SUMIFS.


SG

Apr 10, 2018 9:05 AM in response to SGIII

What I am getting at here is a bit wierd. Let's say the table has 3 women and 6 men. If I filter on women there are 3 rows in the table visible and men have 6 visible. Will I need to re-drag the sum each time or will it continue to work ? And will it continue to work if the table gets bigger - 6 men and 20 women ? Or does it simply add those original 3 rows no matter what replaces them in the future ?

Apr 10, 2018 9:14 AM in response to kevinfromherndon

The formula is hardwired to the original three rows. When you add rows, or there is a sex change operation, you'll need to re-drag. It's a really handy thing for getting a quick subtotal, particularly for a complex filter that would be time-consuming to replicate with SUMIF and SUMIFS, etc.


But if the data undergoes frequent updates and you need an automatically updating summary, you'll need SUMIF and SUMIFS.


Suggest you try it out when you have access to Numbers.


SG

Apr 10, 2018 12:11 PM in response to kevinfromherndon

"When you formatted Column A of the Summary Tables as Automatic did it pick up the Black hair on its own or did you have to add it yourself ?"


Hi Kevin,


You can set the tables up to add new categories to the Summary table(s) as they are added to the Data table. Here's a sample, using your initial data, and adding the two rows in Ian's extended set.

User uploaded file

Data has an added column, G, to hold an index marking the first row where each hair colour appears. The index is created by the formula shown below the table, entered in G2, then filled down to the bottom cell of the table. The column may be hidden (and should be, to help prevent accidentally 'editing' the formula).


The Summary table contains two formulas:


A2: IF(ROW()−1>MAX(Data::G),"",INDEX(Data::F,MATCH(ROW()−1,Data::G,0)))


The core formula, in bold, uses match to find the index value for this row ( ROW()-1 ) in column G of Data, and passes that back to INDEX, which returns the value in the indexed row of column F.

The part of the formula in normal text checks the index value for this row against the maximum value in the index column, and prevents the calculation when all colours have been listed.


B2: SUMIF(Data::F,A2,Data::D)


Sums all rows of column D of Data where that row of column F shows the same label as in A2 of 'this table'.


Both formulas are filled down to the last row of the table.


When rows are added to Data, the formula in column G is automatically filled into the new rows, and new index values are calculated as needed.


When rows are added to the Summary table, the formulas in both columns are automatically filled into the new row(s), and their results are displayed:

User uploaded file

Here, I've added only the age and hair colour data to Data, as these are the only entered values that enter into the calculation on this summary table.


I added two rows to Summary to show the results when there are more rows than needed.

With the extra row (7), a zero result is displayed in column B until there is a new colour recorded in Data::F, at which point the new colour will be immediately added in the empty row, as will the sum of age(s) for that colour.


Regarding 'dynamic' pop-up menus:

Not a supported feature, but you can easily create new or add to existing menus.



All selected cells in the table originally contained text. By selecting the cells, then changing the Data Format from Automatic to Pop-Up menu, Numbers changes all of these cells to Pop-Up menu cells, each containing the four items shown, in the order they individual items first appeared in the list, and each set to the item matching the text that was in that cell.

User uploaded file

To add "Black" to the menu, I

added rows to the table to accommodate the two new entries,

selected the two new 'Hair' cells and changed their format to Text,

Entered "Black" in both cells,

Selected the two cells AND at least one of the pop-up menu cells above it,

Then changed the Data Format pop-up from Multiple to Pop-Up menu, with the results shown below:

User uploaded file

All selected cells now contain pop-up menus with the five items shown.

Unselected cells in the same column still contain the previous version of the pop-up, with only the first four items.

Edited cells maintain their original pop-up settings.


Regards,

Barry

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.

Subtotal filtered columns

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