+ Reply to Thread
Results 1 to 16 of 16

SUMPRODUCT that filters result with each new condition added

  1. #1
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Question SUMPRODUCT that filters result with each new condition added

    Hello all,

    I have a large dataset for email data in one tab - called ALL TIME - and in my STATS sheet, I am using the following SUMPRODUCT to fetch it based on several criteria; year, quarter, model, type of email, etc

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    BUT when I want to have a query which starts by showing all data for that year, then when I add quarter, it just shows that, then when I add email type, just shows by year/quarter/email type and so on.

    I am currently using;

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    But it needs all fields filled in in the filter cells G84 down to G87 to show a result, and doesn't start by showing all data for year if filter 1 is filled, but filters 2 onwards are blank.

    Example;
    • Cell G84 shows year selected
    • Cell G85-87 are empty
    • Data returned should be for whole year
    • BUT
    • When I add the Quarter to cell G85, it should adjust the result to show data from that year and then only that quarter.
    • It should filter down further if anything in the range from the first two criteria is found for filters 3 in cell G86, and then filter 4 in cell G87


    I'm not easily able to strip out and attach a sheet at this stage due to the nature of my source file, so have tried to add this info above.

    Hoping someone can help steer.

    Thanks,

    Ian

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: SUMPRODUCT that filters result with each new condition added

    The DSUM formula will work perfectly for you. Have a read here: https://www.techonthenet.com/excel/formulas/dsum.php
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: SUMPRODUCT that filters result with each new condition added

    Thanks -many of my dropdown criteria are text strings, and also the columns that are searched in the SUMPRODUCT are not adjacent - will this work in those cases?

  4. #4
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: SUMPRODUCT that filters result with each new condition added

    Yup - tried this but;

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    How does the formula know which column to look down for the results... I defaulted the middle digit to 1 as I simply can't adapt the page info you gave my needs?

  5. #5
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: SUMPRODUCT that filters result with each new condition added

    Okay - have tried this;
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    And it does alter result with each extra criteria added in G84, G85, etc - but seems to be adding or mutiplying rather than filtering down with each extra criteria.

    Anyone got any steer please?

    Ian

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: SUMPRODUCT that filters result with each new condition added

    Have a look at this attachment, for a worked example of DSUM.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: SUMPRODUCT that filters result with each new condition added

    Thanks - how does the formula to know to look at sheet1 on your example?
    I ask as I'll need to ensure it looks at my sheet name.

  8. #8
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: SUMPRODUCT that filters result with each new condition added

    @Olly - have managed to get it working- but problem I'm finding with this formula;

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Is that if I go in order - select year, then quarter, then car model, then email type - all fine.
    But if year, quarter, or model are blank, then email type alone returns no values.
    Same true if I do year, then car model without selecting quarter.

    So it's part of the way there - but needs to return values even if not all criteria filled, and if criteria are entered in different order/not at all.

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: SUMPRODUCT that filters result with each new condition added

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  10. #10
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: SUMPRODUCT that filters result with each new condition added

    @Olly - sorry for the delay - as in my OP, I was reluctant to put a trial sheet simply as the sheet is VERY hard to desensitize - that said, it's now attached.
    You'll see my STATS page has the filter - the ALL TIME sheet has the data and the LISTS sheet is just that.
    Ignore the blank columns in ALL TIME which do need to be there in - I simply removed the contents of them for this purpose.
    The filter works with YEAR, and then when QUARTER added, then stops output with further filter.

    Also, I need this to work if YEAR is blank but I add Q1 (for example) - and it outputs all Q1 regardless of year.
    Same is true is I select MODEL and not YEAR or QUARTER, or EMAIL TYPE, and no other criteria.

    If I removed a criteria, I need the output to adjust - removing that 'filter'

    Thoughts?
    Attached Files Attached Files

  11. #11
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: SUMPRODUCT that filters result with each new condition added

    The only error I can see is your field header in Stats!D1 doesn't match the source field header in 'ALL TIME'!L2.

    Change this from 'Model Feat.' to 'Model Featured' and it does exactly what you want.


    Looking at what you're trying to achieve though, I would be using a pivot table... This saves you having to maintain the list of distinct values for each field, it's really easy to adapt to a dynamic source range and refresh, and you can use slicers to control multiple pivot table views of your data. A quick example is in the attached file.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: SUMPRODUCT that filters result with each new condition added

    @Olly - thanks for the header info - appreciated and something I should have spotted.

    My one blindspot is pivots - I need to find a formula based solution, so can we assume pivots don't exist for the purposes of this. Also, the sheet is being built by me but used by colleagues with less excel knowledge so needs to be a simply dropdown select filter as specified.

    HAVING SAID ALL OF THAT - fixing the header names for MODEL FEATURED and TYPE (not Email Type as I had) fixes things and it works as I need it to - so DSUM does do what I specified in my post #10 - I'd just not matched the column names properly. Thank you for the solution.

  13. #13
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: SUMPRODUCT that filters result with each new condition added

    Quote Originally Posted by iantix View Post
    My one blindspot is pivots - I need to find a formula based solution, so can we assume pivots don't exist for the purposes of this. Also, the sheet is being built by me but used by colleagues with less excel knowledge so needs to be a simply dropdown select filter as specified.
    I'd strongly recommend you get over your reluctance to use pivots - they're usually a far more robust, versatile and scaleable solution than fixed formulae!

    However - if that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. You can also Add Reputation to those who helped you. Thanks.

  14. #14
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: SUMPRODUCT that filters result with each new condition added

    Hi, it's both a reluctance and also a necessity - I'd never assume that most folk has a knowledge of pivots and that's proven true in most cases. If I myself know them really well but I'm creating a sheet for use by those who do not, then that rarely works unless every company had a view to ensure full training is paid for (in time and money sense). For now - I need to fully understand the formula action, and that logic is (I find) easier for people to adopt.
    Will of course marked solved - thanks again.

  15. #15
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: SUMPRODUCT that filters result with each new condition added

    With respect, you yourself didn't have the understanding to make your 'SUMPRODUCT' approach work... so it's a pretty safe bet that your users won't find the DSUM solution any more or less new and unknown than a pivot table...

    One of the best things about pivot tables is that end users don't have to understand them, to use them. Especially when you use well placed slicers, the reports then become intuitive click / get results. Most end users don't need to concern themselves with HOW the result is presented.

    If the concern is for auditing and supporting, rather than training end users, then again I suggest Pivot Tables are more robust. Your data and business logic is stored in ONE place, and become reuseable.

    The other consideration, is being able to scale up to Modern Excel - Power Query, Power Pivot, Power BI. It's much easier to begin to understand these new (and vastly improved) ways of manipulating and presenting data, with a solid understanding and use of existing pivot tables.

    Interesting stuff
    Last edited by Olly; 05-24-2017 at 07:14 AM.

  16. #16
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: SUMPRODUCT that filters result with each new condition added

    Thanks - with respect - I'm trying to learn, hence me asking here, and in using these solutions, I'll improve and adapt.
    If pivots become a business necessity for the company, then I'm sure I and others will go there.

+ 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] Help for if condition formula result only either hit or miss from mulitple condition
    By breadwinner in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-09-2013, 07:29 AM
  2. [SOLVED] SUMIFS, SUMPRODUCT with filters etc
    By BC Rob in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-06-2013, 02:49 PM
  3. SUMPRODUCT Function with Filters
    By R_ka_Tect in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-18-2013, 10:03 AM
  4. Two IF statements that result in added text to cell
    By daedelous00 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-13-2012, 10:22 AM
  5. Replies: 2
    Last Post: 10-20-2011, 05:41 AM
  6. Result in added text box
    By tahiraziz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2011, 08:39 AM
  7. SUMPRODUCT and filters
    By richandjo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-04-2011, 03:48 PM
  8. Replies: 5
    Last Post: 01-23-2010, 01:32 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