+ Reply to Thread
Results 1 to 31 of 31

Sumproduct + countifs

  1. #1
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Question Sumproduct + countifs

    Hello,

    I can't connect Sumproduct and Countifs in my example that you can find in the attachment.

    Within the file I've described the problem.

    Therefore, if someone can look into the file, I would appreciate it.

    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    Date in B1 was wrong

    01/02/2016 not 12/02/2016

  3. #3
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Oooo, I see. Thanks!
    Last edited by toci; 03-27-2016 at 10:29 AM.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    Change your date in B1 to 01/02/2016 (as per my previous note)

  5. #5
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Quote Originally Posted by JohnTopley View Post
    Change your date in B1 to 01/02/2016 (as per my previous note)
    Again, I put wrong info in A1. I mean, the Date is the end of the Week, not just the Month.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    If you just want the results for February (or any month) then with the correct date in B1 (which should be 01/mm/2016 where mm is required month) you will get the correct results. You don't need the week number.

  7. #7
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    In B1 I need to put the END Date of the Week as I produce report on a Weekly basis.
    Therefore, tomorrow e.g. I'm gonna change date in B1 like 2/19/2016 and then I need AVERAGE for all Weeks in February. How to pull out Date from B1 like month and compare it with Date in range B4:BC4?
    So, I am not able to put Date in B1 like 2/1/2016 (February 2016).

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    You need to understand your current formula:

    =SUMPRODUCT((MONTH($B$4:$BC$4)=MONTH($B$1))*($B6:$BC6))/COUNTIFS(B4:BC4,B1,B6:BC6,">0")

    SUMPRODUCT sums the data where month=2 (in this case) so if any week is zero it does not matter i.e. 865 + 802 + 900 + 0 for February
    .

    COUNTIF checks B1 against B1:Bc4: the latter have dates of 1st of month for every month NOT the individual week dates.

    You then check if data if a row (6 in this case) is > 0 so if only 3 weeks in February have data so COUNTIF will return 3.

    SUMPRODUCT will only have add " weeks data (as other are zero) so you will get correct average.

    If I make last week in Feb 1000 for product AAA, the total for February is 3567, divide by 4 = 891.75

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    Alternative ..


    .=AVERAGEIFS($B6:$BC6,$B5:$BC5,">=" &$B$2,$B5:$BC5,"<=" &$B$3)

    where B2 = "Week 6" and B3 = "Week 8"

  10. #10
    Forum Contributor
    Join Date
    09-24-2012
    Location
    York, England
    MS-Off Ver
    Excel 2003/07/10
    Posts
    165

    Re: Sumproduct + countifs

    Quote Originally Posted by JohnTopley View Post
    Change your date in B1 to 01/02/2016 (as per my previous note)
    If the date in B1 needs to be (e.g.) the current date, then you could use SUMPRODUCTfor both parts of your formula, as:

    =SUMPRODUCT((MONTH($B$4:$BC$4)=MONTH($B$1))*($B6:$BC6))/SUMPRODUCT(--(MONTH($B$4:$BC$4)=MONTH($B$1)),--($B$6:$BC$6>0))

  11. #11
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    My original formula was =SUMPRODUCT((MONTH($B$4:$BC$4)=MONTH($B$1))*($B6:$BC6)) and now I want to find AVERAGE for Month to Date for Current month.
    In cell B1 I can't put Date like you told me 01/02/2016 as I must to put there Week END Date as I have also formulas which are connected on number of Week. That means for February in B1 I will have next dates:
    2/12/2016, 2/19/2016, 2/26/2016 and so on.
    So, if my formula isn't good can you tell me the new one?
    Thank you.

  12. #12
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Quote Originally Posted by Hercules1946 View Post
    If the date in B1 needs to be (e.g.) the current date, then you could use SUMPRODUCTfor both parts of your formula, as:

    =SUMPRODUCT((MONTH($B$4:$BC$4)=MONTH($B$1))*($B6:$BC6))/SUMPRODUCT(--(MONTH($B$4:$BC$4)=MONTH($B$1)),--($B$6:$BC$6>0))
    The number of Week in cell B2 is very important! If I change the Date e.g. in B1 1/12/2016 (January 12, 2016) then I need Average of the first 3 Weeks in January.
    Last edited by toci; 03-27-2016 at 12:08 PM.

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    Use the AVERAGEIFS formula where you specify a start and end period. post #9

  14. #14
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Quote Originally Posted by JohnTopley View Post
    Use the AVERAGEIFS formula where you specify a start and end period. post #9
    If I knew how, I wouldn't ask.

  15. #15
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Quote Originally Posted by JohnTopley View Post
    Alternative ..


    .=AVERAGEIFS($B6:$BC6,$B5:$BC5,">=" &$B$2,$B5:$BC5,"<=" &$B$3)

    where B2 = "Week 6" and B3 = "Week 8"
    Doesn't work!

  16. #16
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    Sorry it does: I tested on your data.

    See attached .. result in "green" cell
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    09-24-2012
    Location
    York, England
    MS-Off Ver
    Excel 2003/07/10
    Posts
    165

    Re: Sumproduct + countifs

    Quote Originally Posted by toci View Post
    now I want to find AVERAGE for Month to Date for Current month.
    The number of Week in cell B2 is very important!
    Your original formula doesn't mention B2!
    My modification to it #10, will give the Month to date Average provided that the date in B1 is in the Month of interest. Does that work for you ?

  18. #18
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    I've explained with BLUE color. Still this is not what I want to calculate.
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    09-24-2012
    Location
    York, England
    MS-Off Ver
    Excel 2003/07/10
    Posts
    165

    Re: Sumproduct + countifs

    Quote Originally Posted by toci View Post
    I've explained with BLUE color. Still this is not what I want to calculate.
    So you dont want Average month to date then, as you said above (#11 I think), as your blue highlight doesn't include the last week! If you want a part periods figures, then Johns AVERAGEIFS is the way to go

  20. #20
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    I have offered several solutions: if you persist in using a date then make B3 the start week and change the AVERAGEIFS accordingly. You need to define a start and end date/week number so in your sample B3 = Week 6.

    It is not that difficult!

  21. #21
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    If you had checked my response properly you would have worked out I included weeks 6 to 9 (not 8) with Week 9 containing 1000. Hence the result of 950!!!

  22. #22
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Quote Originally Posted by Hercules1946 View Post
    So you dont want Average month to date then, as you said above (#11 I think), as your blue highlight doesn't include the last week! If you want a part periods figures, then Johns AVERAGEIFS is the way to go
    Month to Date means if I have in B1: 2/19/2016 that Date is the END of Week 8. B1 refers that we are in February. So, I need to find AVERAGE of All Weeks till Week 8 for that Month. I have tried AVERAGEIFS for January and can't get AVERAGE that I need.
    I am not sure if we understand each other?

  23. #23
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Quote Originally Posted by JohnTopley View Post
    If you had checked my response properly you would have worked out I included weeks 6 to 9 (not 8) with Week 9 containing 1000. Hence the result of 950!!!
    Sorry, but how did you get AVERAGE of 950 if you put value 1000 in J6. In this case I need average of Week 6 + Week 7 + Week 8 + Week 9, and that is 892? Still cant understand you.

  24. #24
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    See table in A16 onwards:
    Attached Files Attached Files

  25. #25
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Quote Originally Posted by JohnTopley View Post
    See table in A16 onwards:
    Nope man, this is very close to solution but if I change the date in B1 and put e.g. 1/12/2016 (January, 12) get error and it's OK. I change Week in B3, put Week 1 and it's work but if I keep Week 1 in B3 and then, again, change the Date in B1 to e.g. 2/12/2016 (February, 12) don't get correct AVERAGE. I would like to avoid manually changing starting Week. Is it possible?
    Thank you very much on patience.

  26. #26
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    Assuming 12/02/2016 is Week 7, then I don't have any problem with the averages (with B3=Week 1)

    For AAA Weeks 1 to 7 SUM(B6:H6) =4818 and average=4818/7 = 688.29

    This is the result I get in B18.

    Date in B1=12/02/2016

    With B1=01/01/2016 and B3= Week 1 the average is the value for 1st week in January.

  27. #27
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Quote Originally Posted by JohnTopley View Post
    Assuming 12/02/2016 is Week 7, then I don't have any problem with the averages (with B3=Week 1)

    For AAA Weeks 1 to 7 SUM(B6:H6) =4818 and average=4818/7 = 688.29

    This is the result I get in B18.
    That's why we don't understand each other. If we put in B1 12/2/2016 (February, 12) it's indicate Week 7 and that's correct. But B1 indicate that we are in February (don't need data from January) and I need AVERAGE for Current month (in this case it is February) but as I said, I need current Month to date Average, so that should be only (Week 6 + Week 7) and to get Average of 834 not 688,29.

  28. #28
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    My final offer (as your original formula worked fine if you only wanted to sum a single month!)

    in B3

    ="Week"&" "&WEEKNUM(EOMONTH($B$1,-1)+1,16)

    the highlighted will give 1st of the month in B1

  29. #29
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Sumproduct + countifs

    Quote Originally Posted by JohnTopley View Post
    My final offer (as your original formula worked fine if you only wanted to sum a single month!)

    in B3

    ="Week"&" "&WEEKNUM(EOMONTH($B$1,-1)+1,16)

    the highlighted will give 1st of the month in B1
    Your final offer is like a CHARM! Thank you sir!
    This is what I need!
    Cheers!

  30. #30
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Sumproduct + countifs

    A somewhat frustrating journey!

    If you now have your solution, can you please mark thread as solved ("Thread Tools" at top of first post)

  31. #31
    Forum Contributor
    Join Date
    09-24-2012
    Location
    York, England
    MS-Off Ver
    Excel 2003/07/10
    Posts
    165

    Re: Sumproduct + countifs

    Quote Originally Posted by toci View Post
    Month to Date means ???
    I am not sure if we understand each other?
    Month to Date is a standard term used in Accountancy Which means the latest estimate available for the month/period in question.
    So..... if you have figures completed for 3 weeks then the total of these would be MTD.
    It appeared that you understood this, because your initial formula was calculating an average for the 3 completed weeks of period 2, namely 855.67 (6,7 and 8), and NOT P2 till the date in B2, which would be just Weeks 6 and 7.
    Turning to your comments the AVERAGEIFS, your computer can only work with the instructions its given. The reason you have an average of 950 in your attachment is because you have changed the week selection from John's Weeks 6-9 (average 891.75) to only Weeks 8-9 (average 950) both of which are correct with the parameters provided.

    My advice to you is to step back and think through where you want to get to, and make sure you understand how the functions your using actually work. John has done a lot of explaining to help you with this in his posts. This will (hopefully) mean that you won't keep adding/changing your data and/or expected results without keeping the formulae in line. As a footballing friend used to say:
    If you keep moving the goalpost, we'll never get the ball in the net
    Last edited by Hercules1946; 03-27-2016 at 04:18 PM.

+ 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. CountIFS with and operator or SUMPRODUCT?
    By raptor3624 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-25-2016, 03:36 AM
  2. [SOLVED] CountIfS and SUMPRODUCT need help
    By rschoenb in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-12-2014, 11:21 PM
  3. [SOLVED] Sumproduct/countifs
    By mahat in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-21-2014, 10:30 PM
  4. COUNTIFS and SUMPRODUCT help
    By Stacy1 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-19-2013, 02:35 PM
  5. CountIFS and SUMPRODUCT Combined??
    By nobodyukno in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-10-2013, 01:59 PM
  6. Convert CountIFs into SumProduct
    By gingank in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2012, 09:25 PM
  7. Using SUMPRODUCT instead of COUNTIFS
    By SymphonyTomorrow in forum Excel General
    Replies: 12
    Last Post: 11-18-2011, 05:01 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