+ Reply to Thread
Results 1 to 15 of 15

SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

  1. #1
    Registered User
    Join Date
    04-18-2017
    Location
    Berlin, Germany
    MS-Off Ver
    2009
    Posts
    4

    SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Hi,

    quick and simple question I have a data set with products, prices, product categories, revenues and quantities sold. I want to sum (or average, but let's stay with sum for this question) the quantities based on top 5 revenue-generating products based on category, and a price range (0,8*Price and 1,2*Price).

    Thank you!

    Julian
    Last edited by excelmasterofdisaste; 04-19-2017 at 10:18 AM.

  2. #2
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Hi,

    a very quick attempt: a sample file would be helpful.

    In column C product categories

    In column D revenues

    I use an helper column G to get a list of sums of revenues per category

    =IF(COUNTIF($C$2:C2,C2)=1,SUMIF(C:C,C2,D:D),"")


    The formula (AGGREGATE available from Excel 2010)

    =SUMPRODUCT(AGGREGATE(14,6,G1:G1000/((B1:B1000>=0,8)*(B1:B1000<=1,2)),ROW(1:5)))

    sums first 5 top categories per revenue.

    Pivot table probably are the best resource to achieve this output.

    Hope it's a little help
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Registered User
    Join Date
    04-18-2017
    Location
    Berlin, Germany
    MS-Off Ver
    2009
    Posts
    4

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Hi Glenn and Canapone,

    thank you so much for your response. I've attached an example excel which should give a good overview of what I am trying to do.

    I look forward to your feedback.

    Thanks!

    Julian
    Attached Files Attached Files

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Hi. Use this array formula:


    =SUM(LARGE(IF($D$5:$D$66=$H$5,IF($C$5:$C$66>=$J$5,IF($C$5:$C$66<=$K$5,$F$5:$F$66)),0),{1,2,3,4,5}))


    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-18-2017
    Location
    Berlin, Germany
    MS-Off Ver
    2009
    Posts
    4

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Hi Glenn,

    thank you! The only thing this doesn't account for is the ranking by revenue, currently the function ranks and summs the quantity by size. Quantity however should be summed according to size of revenue. How would you go about this?

    Thank you!

    Julian

  7. #7
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Hi All,

    not sure

    I'm using an helper column reading quantities

    In G5

    =IF(COUNTIFS($B$5:B5,B5,$D$5:D5,D5)=1,SUMIFS(F:F,B:B,B5,D:D,D5,C:C,">="&$J$5,C:C,"<="&$I$5),0)

    In M5 first 5 results:


    =SUMPRODUCT(LARGE((D5:D66=H5)*(C5:C66<=I5)*(C5:C66>=J5)*G5:G66,ROW(1:5)))

    Maybe I'm misunderstanding your needs.

    Please refer to the attachment.

    Regards
    Attached Files Attached Files

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Is this correct?? (In the absence of an expected answer it's a bit of a guess...) the yellow cell.

    =SUM(LARGE(IF($D$5:$D$66=$H$5,IF($C$5:$C$66>=$J$5,IF($C$5:$C$66<=$K$5,$E$5:$E$66)),0),{1,2,3,4,5}))

    array entered, as previously
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-18-2017
    Location
    Berlin, Germany
    MS-Off Ver
    2009
    Posts
    4

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Hi Glenn,

    No, sorry for the confusion. I've attached two examples (1 short, 1 long) to make it clearer.


    - Sum Quantity of products, based on:
    - Top 5 of sales within "main category"
    - Within specified price range

    I hope this is clearer. Thank you so much for your repeated efforts!!

    Julian
    Attached Files Attached Files

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    We're not there yet. Maybe it's me being thick... but.

    In example long, I have filtered by Category A. The five values that make your expected result are not all eligible as two (red) falls outside the acceptable price range (row 45 & 53). Can you have another go???

    Edit: I should have added: I am convinced that this formula (array) is correct:

    =SUM(LARGE(IF($D$8:$D$69=$B$5,IF($C$8:$C$69>=$D$5,IF($C$8:$C$69<=$E$5,$F$8:$F$69)),0),{1,2,3,4,5}))

    which (with a few changes to the range) was posted by me back at Post #5????!!!
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 04-20-2017 at 12:58 PM.

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range



    In the sample post#9 you show anticipated results cell H5 of =F8+F27+F45+F51+F53

    But C45 and C53 are < 64. They are 32.00 € and 36.00 €.

    Would you explain why they are included in H5
    Dave

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    This is the only way I can come up with your proposed figure, and I have difficulty believing it is correct given the instructions.

    =SUMPRODUCT(MMULT(--(LARGE(($D$8:$D$69=$B$5)*($C$8:$C$69<=$E$5)*$E$8:$E$69,{1,2,3,4,5})=$E$8:$E$69),{1;1;1;1;1}),$F$8:$F$69)

  13. #13
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Also this array entered.

    =SUM(IF(LARGE(($D$8:$D$69=$B$5)*($C$8:$C$69<=$E$5)*$E$8:$E$69,{1,2,3,4,5})=$E$8:$E$69,$F$8:$F$69))

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    Quote Originally Posted by FlameRetired View Post


    In the sample post#9 you show anticipated results cell H5 of =F8+F27+F45+F51+F53

    But C45 and C53 are < 64. They are 32.00 € and 36.00 €.
    Exactly my point frpom Post # 10...

  15. #15
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMIFs and AVERAGEIFs for LARGE N with multiple criteria & range

    @ Glenn, oops! My bad. I missed that part.

    The only way I could get it to return 1024 was if I removed the $C$8:$C$69>=$D$5 criteria and apply LARGE to the Total sales.

    Neither change fits the instructions.
    Last edited by FlameRetired; 04-21-2017 at 12:09 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. AVERAGEIFS with multiple criteria on one range
    By ctsmith84 in forum Excel General
    Replies: 7
    Last Post: 04-23-2020, 11:31 PM
  2. [SOLVED] SUMIFS/AVERAGEIFS across multiple columns
    By keith740 in forum Excel General
    Replies: 30
    Last Post: 06-25-2015, 01:25 PM
  3. [SOLVED] AverageIFS multiple criteria in one range
    By AndreaJean18 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-02-2015, 10:30 AM
  4. [SOLVED] Macro for AverageIFS, with multiple criteria in the same criteria range
    By Faridwahidi in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 05-24-2014, 01:13 AM
  5. [SOLVED] AverageIFS (or even SUMIFS/COUNTIFS) on large data set
    By natetheblade in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-13-2013, 01:37 AM
  6. Replies: 3
    Last Post: 11-21-2012, 04:57 PM
  7. Replies: 1
    Last Post: 05-16-2011, 05:00 PM

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