+ Reply to Thread
Results 1 to 11 of 11

Sumproduct with date criteria in headers

  1. #1
    Registered User
    Join Date
    03-23-2016
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    6

    Sumproduct with date criteria in headers

    I have a Data Table that shows different accounting values in the rows with each column representing a monthly sum. The headers of each column in are the form of months (i.e. Jan-16, Feb-16). I am trying to create a new table that will allow me to calculate the sums for each year and yet another that will calculate monthly averages.

    The original data table is named "dMonthlyData" and looks like:

    Measurement 16-Jan 16-Feb
    Sales 2,000,000 3,000,000
    Costs 1,500,000 1,750,000

    The sumproduct formula I'm trying to use looks like: =SUMPRODUCT((dMonthlyData[#Data])*(dMonthlyData[Measurement]="Sales")*(YEAR(dMonthlyData[#Headers])=2016))

    So, the criteria is to get the sum (or average) of all the data in a particular row that happen to be in the columns where the header has a 2016 date. Is this possible without doing a PivotTable?
    Last edited by CoachScotticus; 03-23-2016 at 02:48 PM. Reason: Solved

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Sumproduct with date criteria in headers

    1. It would help to see the workbook.

    You get better help on your question if you add a small excel file, without confidential information.

    Please also add manualy the expected result in your file.

    To Attach a File:

    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.

    What is the reason you don't want to use a pivot table?
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Sumproduct with date criteria in headers

    Try

    =SUMPRODUCT((dMonthlyData[[1/16/2016]:[2/16/2016]])*(dMonthlyData[Measurement]="Sales")*(YEAR(dMonthlyData[[#Headers],[1/16/2016]:[2/16/2016]])=2016))

  4. #4
    Registered User
    Join Date
    03-23-2016
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    6

    Re: Sumproduct with date criteria in headers

    Please see attached...

    I don't want to use a PivotTable because 1.) I lose the formatting of my row headers (i.e. Sales, etc.) and I have some years in the past without monthly data but rather could only recover the yearly info.

    Thank you for your help.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-23-2016
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    6

    Re: Sumproduct with date criteria in headers

    For some reason, this does not work either. A dialogue box opens saying that the formula is incorrect. It looks like the reason is because the Header is not the same.

    Try

    =SUMPRODUCT((dMonthlyData[[1/16/2016]:[2/16/2016]])*(dMonthlyData[Measurement]="Sales")*(YEAR(dMonthlyData[[#Headers],[1/16/2016]:[2/16/2016]])=2016))

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Sumproduct with date criteria in headers

    The problem you have is that the headers of the first table (Jan-12 and Feb-12) are NOT really dates.
    They're just text strings "Jan-12"

    Then when you apply the YEAR function to those cells, Excel does it's best to guess at the date it represents.
    And Excel is interpraiting those dates as January 12th 2016 and February 12th 2016.
    So the YEAR function is returning 2016, not 2012.

    Try
    =SUMPRODUCT((dMonthlyPL[[Jan-12]:[Feb-12]])*(dMonthlyPL[Measurement]=[@Measurement])*(YEAR("28-"&dMonthlyPL[[#Headers],[Jan-12]:[Feb-12]])=2012))

  7. #7
    Registered User
    Join Date
    03-23-2016
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    6

    Re: Sumproduct with date criteria in headers

    Very interesting. Just out of curiosity for my understanding, what is the "28-"& part telling Excel to do?

  8. #8
    Registered User
    Join Date
    03-23-2016
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    6

    Re: Sumproduct with date criteria in headers

    Very interesting. Just out of curiosity for my understanding, what is the "28-"& part telling Excel to do?

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Sumproduct with date criteria in headers

    Well
    YEAR("Jan-12)

    It's being interpraited as January 12th 2016
    Year 2016 is assumed because no year was provided by the string
    Only 2 elements of the date were provided Jan and 12.
    Jan is obviously January.
    But what is the 12 meant to be? Is that the DAY or the YEAR ?
    Excel essentially made the assumption that you meant the 12 to be the DAY.
    So it filled in the remaining/missing piece of a complete date, the YEAR.
    When no year is provided, current year is assumed.

    YEAR("28-Jan-12")

    Now all elements of a complete date are provided.
    And with that format, it correclty assumes the number at the end of the string is the year.

    Not sure why I picked 28 for the day, I suppose you could use any Day # from 1 to 28.
    Last edited by Jonmo1; 03-23-2016 at 03:14 PM.

  10. #10
    Registered User
    Join Date
    03-23-2016
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    6

    Re: Sumproduct with date criteria in headers

    Excellent. Thank you for your help with this.

  11. #11
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Sumproduct with date criteria in headers

    You're welcome.

+ 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. Replies: 1
    Last Post: 02-03-2016, 02:33 AM
  2. Sumproduct - Count more than one criteria by date
    By drivera74 in forum Excel General
    Replies: 16
    Last Post: 08-19-2015, 10:35 AM
  3. [SOLVED] SUMPRODUCT with Date Range and a Criteria
    By Dhoang25 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-10-2015, 02:48 PM
  4. Using SUMPRODUCT to look a date criteria.
    By mtahboub in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-06-2012, 01:47 AM
  5. Sumproduct using date criteria
    By Turbo68 in forum Excel General
    Replies: 2
    Last Post: 04-03-2012, 03:46 PM
  6. [SOLVED] sumif or sumproduct with date as criteria
    By jhahes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-02-2005, 12:59 PM
  7. Sumproduct w/date criteria not working
    By JANA in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-15-2005, 07:06 AM

Tags for this Thread

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