Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

Multi Criterion & Sumproduct

Latest post Tue, Mar 22 2011 11:56 PM by noaman. 9 replies.
  • Tue, Mar 15 2011 4:13 AM

    • noaman
    • Top 150 Contributor
    • Joined on Tue, Mar 15 2011
    • Posts 6
    • Points 94

    Multi Criterion & Sumproduct

    Hello,

    Would highly like if you could shed some light on how I can accomplish this.

    My sheet has three segments. The first being a selection for the users (the user can choose which category they want to view the reports for):

    Selection
    # Category Include?
    1 Electricals Yes
    2 Paper Yes
    3 Food Yes
    4 Beverages No
    5 Pets No
    6 Cosmetics No

    The second segment has sales records

    Sales
    Year Month Category Quantity
    2010 1 Electricals 5
    2010 1 Paper 434
    2010 2 Electricals 23
    2010 2 Food 13
    2010 3 Beverages 2323

    And, the third has performance summary / report based on year-month against the selected criterions in the first sheet

    Summary / Report
    Year Month Quantity
    2010 1 ???
    2010 2 ???
    2010 3 ???

    The max I've reached for the formula against Quantity is as follows:

    =SUMPRODUCT(($C$16:$C$20=D26)*($D$16:$D$20=E26),$F$16:$F$20)

    but, this doesnt consider the selection that the user has made, and as such the totals are coming up. I'm aware that I can use PivotTable with ease for this requirement, but I'd ideally prefer a non-PivotTable solution as there are many other dependencies.

    Thanks in advance!

    Noaman 

     

    Thanks

    Noaman

     

    • Post Points: 21
  • Tue, Mar 15 2011 5:04 AM In reply to

    • Roger Govier
    • Top 10 Contributor
    • Joined on Wed, Jan 9 2008
    • Abergavenny, South Wales, UK
    • Posts 207
    • Points 3,169
    • MVP

    Re: Multi Criterion & Sumproduct

    Hi Noaman

    Sustitute the range where you have your seelctions, Yes and No for the word "include" in the following formula

    =SUMPRODUCT(($C$16:$C$20=D26)*($D$16:$D$20=E26)*(include="Yes"),$F$16:$F$20)

    Regards
    Roger Govier
    Microsoft Excel MVP

    • Post Points: 36
  • Tue, Mar 15 2011 5:33 AM In reply to

    • noaman
    • Top 150 Contributor
    • Joined on Tue, Mar 15 2011
    • Posts 6
    • Points 94

    Re: Multi Criterion & Sumproduct

    Thanks Roger!

    Works as a charm - appreciate the quick response too

    Ta,

    N.

    • Post Points: 5
  • Thu, Mar 17 2011 6:12 AM In reply to

    • noaman
    • Top 150 Contributor
    • Joined on Tue, Mar 15 2011
    • Posts 6
    • Points 94

    Re: Multi Criterion & Sumproduct

    Hello again!

    Wondering if its possible with the same example to actually count the distinct values in the given column

    I'm aware that I can get distinct count (including text) by saying: =SUM(IF(FREQUENCY(IF(LEN(H3:H11243)>0,MATCH(H3:H11243,H3:H11243,0),""), IF(LEN(H3:H11243)>0,MATCH(H3:H11243,H3:H11243,0),""))>0,1)) as an array....

    from the formula given by Roger:

    =SUMPRODUCT(($C$16:$C$20=D26)*($D$16:$D$20=E26)*(include="Yes"),$F$16:$F$20)

    is it possible to get distinct count similar to abovementioned so that instead of getting a sum from F16:F20 --> I actually get distinct count from J16:J20?

    Would this be possible without the use of macros?

    Thanks in advance

    • Post Points: 21
  • Mon, Mar 21 2011 5:56 AM In reply to

    Re: Multi Criterion & Sumproduct

    Are you sure that formula works? it is okay for the 2010, 1, but 2010, 2 returns 23 for me, whereas it should be 36.

    Regards

    Bob

    • Post Points: 21
  • Mon, Mar 21 2011 6:06 AM In reply to

    • noaman
    • Top 150 Contributor
    • Joined on Tue, Mar 15 2011
    • Posts 6
    • Points 94

    Re: Multi Criterion & Sumproduct

    The range should be two columns: category & include. Furthermore, the categories have to be sorted alphabetically.

     

    • Post Points: 21
  • Mon, Mar 21 2011 7:20 PM In reply to

    Re: Multi Criterion & Sumproduct

    Does that answer my question?

    Regards

    Bob

    • Post Points: 21
  • Mon, Mar 21 2011 11:36 PM In reply to

    • noaman
    • Top 150 Contributor
    • Joined on Tue, Mar 15 2011
    • Posts 6
    • Points 94

    Re: Multi Criterion & Sumproduct

    Yes, it should be 36. You would be getting 23 if you havent sorted the categories alphabetically. So, to get the correct answer and for the formula to work properly (ie to get correct answer as 36), one should sort the categories alphabetically.

    • Post Points: 21
  • Tue, Mar 22 2011 6:32 AM In reply to

    Re: Multi Criterion & Sumproduct

    Sorry, I am missing something here. You say the answer should be 36, the formula returns 23, but you say it works. It does not compute!

    Regards

    Bob

    • Post Points: 21
  • Tue, Mar 22 2011 11:56 PM In reply to

    • noaman
    • Top 150 Contributor
    • Joined on Tue, Mar 15 2011
    • Posts 6
    • Points 94

    Re: Multi Criterion & Sumproduct

    Hey Bob,

    Turn all the selection off, and then turn then back on - it should work.

    I'll paste my tables once again.

    D2:F9

    Selection
    # Category Include?
    1 1- Electricals Yes
    2 2- Paper Yes
    3 3- Food Yes
    4 4- Beverages No
    5 5- Pets No
    6 6- Cosmetics No

     

    C14:F20

    Sales
    Year Month Category Quantity
    2010 1 1- Electricals 5
    2010 1 2- Paper 434
    2010 2 1- Electricals 23
    2010 2 3- Food 13
    2010 3 4- Beverages 2323

     

    D24:F28

    Summary / Report
    Year Month Quantity
    2010 1 439
    2010 2 36
    2010 3 0

    Formula against F26: =SUMPRODUCT(($C$16:$C$20=D26)*($D$16:$D$20=E26)*(LOOKUP($E$16:$E$20,$E$4:$F$9)="Yes"),$F$16:$F$20)
    Copy paste the F26 formula to F27 & F28 and re-run all selections by turning all off and then back on again.

     

     

     

    • Post Points: 5
Page 1 of 1 (10 items) | RSS
Copyright Excel User Group and the relevant contributors, 2010. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.