+ Reply to Thread
Results 1 to 26 of 26

SUMIF with multiple column and row criteria

  1. #1
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Smile SUMIF with multiple column and row criteria

    Hi All,

    I am looking for some help with a formula for the attached spreadsheet's summary Tab (G5:K6).

    Demo1.xlsx

    The formula needs to be able to read from the Data Tab and:

    1. Total the values in a column based on the country being selected and then multiple expense types being selected by dropdown (up to 3). Formula in G9 does part of this (via help on the forum yesterday).
    2. By changing the year and Month in rows 2 and 3 the summary table should update accordingly.

    I am trying not to use named ranges for the columns and think a sumif/index/match formula may be the way to go but I have tried so many different things that are not working I think my head is about to pop.

    Any help is greatly appreciated.

    Thanks,

    Adam
    Last edited by Zimbo; 03-11-2015 at 11:32 PM.

  2. #2
    Forum Contributor
    Join Date
    10-07-2011
    Location
    India, Mumbai
    MS-Off Ver
    Excel 2007
    Posts
    212

    Re: SUMIF with multiple column and row criteria

    Hi Use this formula in
    Cel G8=
    =SUMPRODUCT((Data!$B$5:$B$17=Summary!$D$5:$F$5)*(INDIRECT("Data!"&ADDRESS(5,MATCH(G3&G2,Data!$D$2:$M$2&Data!$D$1:$M$1,0)+3)&":"&ADDRESS(17,MATCH(G3&G2,Data!$D$2:$M$2&Data!$D$1:$M$1,0)+3))))

    Regards,
    Suhas

  3. #3
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: SUMIF with multiple column and row criteria

    May be like this:
    Please Login or Register  to view this content.
    Click (*) if you received helpful response.

    Regards,
    David

  4. #4
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Hi Suhas,

    The formula does almost exactly want I was hoping for other than it does not allow for the change in the cells in C5 and C6. also if I change the value in D5,E5 and F5 to values that are zero it comes up as N/A.

    Thanks for your help.

    Cheers,

    Adam

  5. #5
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Hi David,

    I have just tried your formula and it seems to do exactly what I was hoping for.

    Thanks so much for your effort.

    Cheers,

    Adam

  6. #6
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Hi David,

    As mentioned before your formula does exactly what I was wanting.

    Do you have any suggestions on how I may be able to add to your formula to give me a per quarter Sumproduct?

    That is totals as per the dropdowns but for the year and then the combined (Q1- Jan, Feb, Mar, April), etc instead of just the month.
    I am guessing I would need to add a row to the Data table to reflect the quarters.

    Apologies for the additional request.

    Thanks and Regards,

    Adam

  7. #7
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: SUMIF with multiple column and row criteria

    Hi, Adam.

    1st I want to know how you want the report looks like? upload the sample, if need adjustment, i will tell you.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: SUMIF with multiple column and row criteria

    Not sure if you got your answer yet, but try this in G5, copied down and across...
    =SUMPRODUCT((Data!$A$5:$A$17=$C5)*((Data!$B$5:$B$17=$D5)+(Data!$B$5:$B$17=$E5)+(Data!$B$5:$B$17=$F5))*(Data!$D$1:$M$1=G$2)*(Data!$D$2:$M$2=G$3)*(Data!$D$3:$M$3=G$4),Data!$D$5:$M$17)

    For qtr and year, it would probably be easier if you used read dates instead of just years and names...1/1/14, 2/1/14 etc
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  9. #9
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: SUMIF with multiple column and row criteria

    Hi, Adam



    As FDibbinss suggest "For qtr and year, it would probably be easier if you used read dates instead of just years and names...1/1/14, 2/1/14 etc ".

    I make a little adjusment for you.

    See the attachment.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Hi David,

    Please see updated Attachment.

    Demo2.xlsx

    Cells N2:N6 show what I hope the Qtr1 report would look like and it is the combined totals of Jan,Feb,Mar

    Qtr2 would be Apr,May,Jun
    Qtr3 would be Jul,Aug,Sep
    Qtr4 would be Oct,Nov,Dec

    In the report I have summed the 3 months to get the total Qtr1 but would like this to be part of the formula as I would normally only want to show the 4 Qtr's per year in the report.

    Also there is the potential that there may be only a partial Qtr i.e only one or two months in the data as per the data in I2:I6.

    I hope that makes sense.

    Thanks and Regards,

    Adam
    Last edited by Zimbo; 03-11-2015 at 01:40 AM.

  11. #11
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: SUMIF with multiple column and row criteria

    Hi, Adam

    Check my post #9, with that you can create the formula, you just need make a little adjustment.

  12. #12
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Hi David and FDibbins,

    Thanks for the suggestion and it could work.

    It would however make the presentation of the report difficult as I need to only show the years and either the months or Qtr's as per my last post.
    It would be difficult to show (or use) a date range in the report.

    I appreciate all the help.

    Cheers,

    Adam

  13. #13
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: SUMIF with multiple column and row criteria

    I don't know your problem solved or not, but if you insist using text for month and year, i give you another option for summary.

    See the attachment.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Hi David,

    I have not solved this as yet.

    I think I will try and use your original solution and add a row below the months in the Data table to show which Qtr's are correct.

    The formula can then look for the year then the Qtr if it is being used instead of the Month.

    I think this should work.

    Thanks for the help.

    Cheers,

    Adam

  15. #15
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: SUMIF with multiple column and row criteria

    I have changed your dates to real dates, and modified the formulas to pull in the month, the QTR and the YTD
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Hi Ford,

    Thanks for that. That will work perfectly.
    I do have one more formula question.
    If I would like to the report on the Summary tab to show results from all the countries in column A, what changes would the formula need?

    Best Regards,

    Adam

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: SUMIF with multiple column and row criteria

    If you want to include all countries, then just remove the test for the country....
    (Data!$A$6:$A$18=$C5)
    take that part out

  18. #18
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Thanks Ford,

    I was thinking more along the lines of adding "All" to the list of countries.

    Regards,

    Adam

  19. #19
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: SUMIF with multiple column and row criteria

    I am out of time right now, I will take a look again soon

  20. #20
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Much Appreciated,

    It would also be handy if there was an "All" in D5:D6.

    Regards,

    Adam

  21. #21
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Hi All,

    I have added If "All" to the sumproduct formulas Ford and David have helped with and it works perfectly.

    Thanks for all the help.

    Adam

  22. #22
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: SUMIF with multiple column and row criteria

    Great stuff. Can you share the formula with us?

  23. #23
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Hi Ford,

    I have ended up going for the original formula (post #3 and #8) and added a third row in my Data table to show the Qtr's as numbers 1-4 (hence the Isnumber to differentiate between month or Qtr). Obviously the references are to my active sheet and it is worth noting this works both on Excel and Google sheets.

    Formula is below.

    =Round(SUMPRODUCT(((If($I6="All",1,'Monthly Budget'!$A$6:$A$469=$I6))*If($J6="All",1,(('Monthly Budget'!$B$6:$B$469=$J6)+('Monthly Budget'!$B$6:$B$469=$K6)+('Monthly Budget'!$B$6:$B$469=$L6)+('Monthly Budget'!$B$6:$B$469=$M6)+('Monthly Budget'!$B$6:$B$469=$N6)))*('Monthly Budget'!$U$1:$DN$1=Q$3)*(If(Isnumber(Q$3), 'Monthly Budget'!$U$3:$DN$3=Q$4,'Monthly Budget'!$U$2:$DN$2=Q$4)))*'Monthly Budget'!$U$6:$DN$469),0)

    Thanks again,

    Adam

  24. #24
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: SUMIF with multiple column and row criteria

    Impressive

  25. #25
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: SUMIF with multiple column and row criteria

    Thanks Ford

    Formula is below with Named Ranges for fixed data columns and rows. It is a little shorter.

    =Round(SUMPRODUCT(((If($I6="All",1,Country=$I6))*If($J6="All",1,((Expense=$J6)+(Expense=$K6)+(Expense=$L6)+(Expense=$M6)+(Expense=$N6)))*(Year=Q$3)*(If(Isnumber(Q$4), Quarter=Q$4,Month_=Q$4)))*Budget),0)

    Cheers,

    Adam
    Last edited by Zimbo; 03-12-2015 at 01:04 AM.

  26. #26
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: SUMIF with multiple column and row criteria

    Looks good Keep in mind that when working with dates, its almost always better to use actual dates, rather than names and years.

    In the WB I uploaded, I forgot to mention that I used ONLY the dates in the top row (1), the other 2 (year) and Month) were not used at all

+ 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. [SOLVED] Multiple Criteria SUMIF Using Column as Negative Criteria
    By freybe06 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-24-2014, 04:46 PM
  2. SUMIF for multiple column/sheet criteria
    By preddy1110 in forum Excel General
    Replies: 1
    Last Post: 04-13-2012, 11:45 AM
  3. Replies: 2
    Last Post: 01-27-2012, 01:32 PM
  4. Multiple Sumif (Criteria within same column)
    By Thanksinadvance in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-20-2011, 09:35 AM
  5. SumIF multiple column criteria
    By gd19 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-05-2008, 05:56 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