+ Reply to Thread
Results 1 to 7 of 7

sum a table based on another filtered table

  1. #1
    Registered User
    Join Date
    11-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007/10
    Posts
    18

    sum a table based on another filtered table

    Hi,

    I'm trying to total a column in a table (table2) based on the filtered result of another table (table1). I thought this would be straightforward using dsum or sumif but both sum on the basis of an unfiltered table

    these are my test tables

    Capture.JPG

    If table1 is filtered to select M gender than the value I need is 90 - sum of A and D's value1's in table 2
    If I filtered on M Gender and 1 Month then the value would be 78 - just sum of A's value1's in table2

    Is there a way for dsum or sumif (or another function) to recognise the filtered list?

    Many thanks in advance

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: sum a table based on another filtered table

    Could you send the sample in excel format?

    a crude way to make the function =sumif() work would be to include the gender and month in table2 (it can be done automatically via formulas, at least the gender part)

  3. #3
    Registered User
    Join Date
    11-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007/10
    Posts
    18

    Re: sum a table based on another filtered table

    tablesumtest.xlsxThanks - please find attached

    Including the gender and month in table2 won't work in this instance (well, it would but would be horribly cumbersome) - it is part of an automated report generation and in the 'real' system there are around 250 columns in Table1 that could be filtered and several table2's that are referenced - and each of those have 20 or 30 columns to be summed. The values actually appear at the bottom of Table1.

    In a database it would not be an issue, but my client insists on using Excel.

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: sum a table based on another filtered table

    try the macro by pressing the button after defining the filter criteria
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007/10
    Posts
    18

    Re: sum a table based on another filtered table

    Hi rcm

    Thanks for the code - I had considered something similar - basically using the xlCellTypeVisible property but was hoping there was an excel function which would do the job. Looks like I'll need to go the code route.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: sum a table based on another filtered table

    You dont really show all the sample data, but 2 2 ways come to mind....
    1. using SUBTOTAL(109,range)
    2. using sumifS() to include only M or only F
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Registered User
    Join Date
    11-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007/10
    Posts
    18

    Re: sum a table based on another filtered table

    thank you for your help. I had to create a function, but the attached does exactly what I require.

    Filter table1 as you like and the values recalculate as they should
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Data Validation Drop down based on Filtered Table
    By Juicy2052 in forum Excel General
    Replies: 1
    Last Post: 09-03-2014, 08:23 AM
  2. Replies: 1
    Last Post: 11-01-2012, 12:28 AM
  3. [SOLVED] Subtotal (if) based on fiscal quarter from filtered table?
    By kmurphy372 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-29-2012, 10:11 PM
  4. Replies: 0
    Last Post: 02-20-2012, 02:53 PM
  5. Automatic update of Pivot Table based on filtered data
    By humacdeep in forum Excel General
    Replies: 4
    Last Post: 02-08-2012, 06:43 AM
  6. Replies: 2
    Last Post: 06-16-2011, 06:53 PM
  7. Replies: 1
    Last Post: 01-06-2006, 02:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1