+ Reply to Thread
Results 1 to 9 of 9

Sum Product - Months, Year Criteria

  1. #1
    Forum Contributor
    Join Date
    05-17-2012
    Location
    CA, USA
    MS-Off Ver
    Microsoft Excel for Microsoft 365
    Posts
    163

    Sum Product - Months, Year Criteria

    I want to sum each month's food costs for a particular year (N4:N15). N4:N15 will be referencing columns A, E and I and summing the costs from columns B, F and J.

    Not sure if there is a function or way to translate month abbreviations so that they filter and match the raw data being entered in. For example, Aug = 18-Aug. I was using the MONTH() function but the abbreviation does not convert the month to a number but the raw data date does. Please advise. Do not go by the current formula in N11, I want to add Breakfast, Lunch and Dinner for any given month out of the year.

    Regards,
    T86157
    Attached Files Attached Files
    Last edited by T86157; 08-21-2012 at 09:47 AM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Sum Product - Months, Year Criteria

    Convert column M to dates. Now it's General Format and Excel does not "understand" that Aug, is a date..

    Type in M11, 01/08/12 and use this Custom Format. ddd. Will show Aug.

    Then use this formula in N11.

    =SUMPRODUCT((MONTH(E4:E1000)=MONTH(M11))*(YEAR(E4:E1000)=M$3)*(F4:F1000))

    Result is 8.41
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Contributor
    Join Date
    05-17-2012
    Location
    CA, USA
    MS-Off Ver
    Microsoft Excel for Microsoft 365
    Posts
    163

    Re: Sum Product - Months, Year Criteria

    My excel date format must be different from yours. 01/08/12 gives me January 8, 2012 instead of August 1, 2012. Same with "ddd", that gives me day and not month. Month I figured out for my excel is "mmm" and 08/01/12 gave me August. Not sure why your particular example procedure give me what you got...

    Oops! I also forgot to add, for the month. So I want to add up all the food costs for the current month of August which includes the columns of Breakfast, Lunch and Dinner. Not just Lunch. I think the formula is a little more complicated than that?
    Last edited by T86157; 08-21-2012 at 09:46 AM.

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Sum Product - Months, Year Criteria

    Apologize for this. Format "mmm", gives you name of the Month.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    05-17-2012
    Location
    CA, USA
    MS-Off Ver
    Microsoft Excel for Microsoft 365
    Posts
    163

    Re: Sum Product - Months, Year Criteria

    Fotis,

    I want to sum not only Lunch for August but Breakfast and Dinner as well.

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Sum Product - Months, Year Criteria

    Try to add 3 Sumproduct. Something like this.

    =SUMPRODUCT((MONTH(E4:E1000)=MONTH(M11))*(YEAR(E4:E1000)=M$3)*(F4:F1000))+SUMPRODUCT((MONTH(A4:A1000)=MONTH(M11))*(YEAR(A4:A1000)=M$3)*(B4:B1000)+SUMPRODUCT((MONTH(I4:I1000)=MONTH(M11))*(YEAR(I4:I1000)=M$3)*(J4:J1000)))

  7. #7
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Sum Product - Months, Year Criteria

    Hi T86157
    As Fotis1991, but using the text function. In cell N4 and drag down.

    =IFERROR(ROUND(SUMPRODUCT(--(TEXT($A$4:$A$1000,"mmm")=$M4),$B$4:$B$1000)+SUMPRODUCT(--(TEXT($E$4:$E$1000,"mmm")=$M4),$F$4:$F$1000)+SUMPRODUCT(--(TEXT($I$4:$I$1000,"mmm")=$M4),$J$4:$J$1000),2),"")

  8. #8
    Forum Contributor
    Join Date
    05-17-2012
    Location
    CA, USA
    MS-Off Ver
    Microsoft Excel for Microsoft 365
    Posts
    163

    Re: Sum Product - Months, Year Criteria

    With either equation, Kevin or Fotis, is there a compact/efficient way of making an IF function so that if the sumproduct is equal to zero, then make the cell blank, otherwise sumproduct. Below is the function:

    Please Login or Register  to view this content.
    The redundancy is found in the sumproduct for the if statement and then for the false statement. Any help on making this more compact and efficient would be greatly appreciated. Please advise. Thank you

  9. #9
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Sum Product - Months, Year Criteria

    Hi T86157

    Option 1: As the formula I posted in thread #7 and uncheck Show a zero in cells that have a zero value. In File, Options, Advanced.

    Option 2: =IF(ROUND(SUMPRODUCT(--(TEXT($A$4:$A$1000,"mmm")=$M4),$B$4:$B$1000)+SUMPRODUCT(--(TEXT($E$4:$E$1000,"mmm")=$M4),$F$4:$F$1000)+SUMPRODUCT(--(TEXT($I$4:$I$1000,"mmm")=$M4),$J$4:$J$1000),2)=0,"",ROUND(SUMPRODUCT(--(TEXT($A$4:$A$1000,"mmm")=$M4),$B$4:$B$1000)+SUMPRODUCT(--(TEXT($E$4:$E$1000,"mmm")=$M4),$F$4:$F$1000)+SUMPRODUCT(--(TEXT($I$4:$I$1000,"mmm")=$M4),$J$4:$J$1000),2))

    Mind you someone else should have a shorter idea.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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