+ Reply to Thread
Results 1 to 13 of 13

Formula to Sum Values from a Column Based on Multiple Criteria

  1. #1
    Registered User
    Join Date
    11-27-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    16

    Formula to Sum Values from a Column Based on Multiple Criteria

    I didn't expect to have so much trouble and I may just be missing something but I'm stuck!

    I have attatched an example workbook with a tiny subset of data and a number of criteria from the Dashboard Engine page removed.

    What I need is to sum the total value for each division on the second sheet based on the date criteria (so for the first cell Jan 1/2010 - Jan 31/2010) and on a match between division name on the Dashboard Engine sheet table and the Masterdata sheet. I have tried a number of variations but keep getting a 0 for each return.
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    Use a pivot table. Use [Date] grouped by Year / Month as Column field, [Division] as Row field, [Sum of Amount($)] as Values field.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    Here, try the attachment to see how it could work.

    Full marks for structuring your source data nicely!
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    11-27-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    I have zero experience with pivot tables so this is a learning opportunity. Thanks Olly. However, I can't get it to sort monthly. When I expand the year columns I have individual days as opposed to monthly totals. I see the "group" option but it is asking me to enter values. Do I have to manually enter the datevalue for each date range? I assume there is a much easier alternative staring me in the face.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    In the Group dialog box, leave both 'Auto' checkboxes ticked to group the whole date range, then select Years and Months in the 'By' list. This should group ALL your dates by Year and Month

  6. #6
    Registered User
    Join Date
    11-27-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    A little lost, I apoligize. If I select the entire "date" row (all the cells with a date) and right-click and group it just autogroups them into "Group1" with no subdivision and no prompt box. If I select all the dates in one month (or any number of cells less than the entire row) I get the following prompt box:

    Sample.png

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    Aha, yes - format your Dates (Masterdata, Column H) as a date numberformat, then the pivot table will treat it as a date field, and allow grouping by year, month, etc

  8. #8
    Registered User
    Join Date
    11-27-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    I tried that first. Masterdata column H is and has been in a number format which is why I'm very confused. Now, Masterdata column G [Year] is not because I'm not sure how to format just a year as a date column. However, the years are sorted fine so I'm not sure this matters. Is it possible excel doesn't see consecutive dates and therefore doesn't want to group them by month? Somedays there is no overtime taken hence gaps in the date sequences.

    I'm so close but still a step away.

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    Quote Originally Posted by MaxwellR View Post
    I tried that first. Masterdata column H is and has been in a number format which is why I'm very confused. Now, Masterdata column G [Year] is not because I'm not sure how to format just a year as a date column. However, the years are sorted fine so I'm not sure this matters. Is it possible excel doesn't see consecutive dates and therefore doesn't want to group them by month? Somedays there is no overtime taken hence gaps in the date sequences.

    I'm so close but still a step away.
    I think you misunderstand me - you need to format column H as a DATE format. It is currently formatted as a number.

    Nonconsecutive / missing dates won't matter; once that column is formatted as DATES, the pivot table will treat them as dates, and you'll be able to group by year / month etc.
    Last edited by Olly; 11-29-2013 at 03:38 PM.

  10. #10
    Registered User
    Join Date
    11-27-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    Sorry I misstyped. Column H is a DATE format.

  11. #11
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    Quote Originally Posted by MaxwellR View Post
    Sorry I misstyped. Column H is a DATE format.
    In the sample you originally posted, column H was formatted as numbers. I reformatted as dates (dd/mm/yy) then created the pivot table - see my attachment above, and look at the grouping of the date field.

    If you are still struggling, can you post your actual workbook, rather than a copied sample, so I can see your real data?

  12. #12
    Registered User
    Join Date
    11-27-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    Got it. The key was I had to recreate the table after I changed the column format to DATE. I assumed, wrongly, that changing it would auto update the formating of the pivot row. Thanks again for all your help Olly. You've taught me tons in the last two days!

  13. #13
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Sum Values from a Column Based on Multiple Criteria

    Quote Originally Posted by MaxwellR View Post
    Got it. The key was I had to recreate the table after I changed the column format to DATE. I assumed, wrongly, that changing it would auto update the formating of the pivot row. Thanks again for all your help Olly. You've taught me tons in the last two days!
    Brilliant - pleased you got it to work, and really pleased you've learned a little along the way. Pivot tables can be excellent, and it looks like a perfect way of reporting on your structure of source data

+ 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. Need Formula to List Values Based on Multiple Criteria
    By lhodgdon in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-20-2013, 05:22 AM
  2. Need a Formula to List Values Based on Multiple Criteria
    By lhodgdon in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-18-2013, 04:08 PM
  3. Replies: 6
    Last Post: 10-18-2012, 03:10 PM
  4. Summing Values in column based upon multiple criteria
    By shantanuk in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-21-2012, 09:29 AM
  5. How to delete multiple values in a column based on Criteria
    By ravi3cha in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2010, 07:00 AM

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