+ Reply to Thread
Results 1 to 10 of 10

Squeezing more conditions into a sample SUMPRODUCT formula - show a novice pls!

Hybrid View

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    helsinki
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Squeezing more conditions into a sample SUMPRODUCT formula - show a novice pls!

    Hi Richard,

    Thank you. I´m making a reporting table. Basically it entails counting alot of values meeting different combinations of conditions. For example count only if one column is F when columns A,B or C has anything entered in it and when the entry is for a date falling between two dates etc. So it is basically counting with alot of IFs.

    I suppose COUNTIFS would better suit my purpose? Would you know the most concise reference on how to use it with multiple conditions like AND OR NOT?

    Many thanks,

    Roger

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Squeezing more conditions into a sample SUMPRODUCT formula - show a novice pls!

    Hi

    Yes a COUNTIFS() function would be infinitely preferable and with a big database far more efficient.

    See if the attached gives you some ideas. Note that I've added a helper column F to test whether at least one of columns A,B or C contains a value. The default standard for a COUNTIFS() function is the AND operator. So without a helper column you would need to add three COUNTIFS() together. i.e.

    =COUNTIFS()+COUNTIFS()+COUNTIFS()

    using columns A, B & C respectively in each one.


    Or of course if your layout lends itself a PivotTable as suggested by Miraun whilst I was typing!
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-27-2012
    Location
    helsinki
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Squeezing more conditions into a sample SUMPRODUCT formula - show a novice pls!

    This is extremely helpful Richard, much appreciated.

  4. #4
    Registered User
    Join Date
    11-27-2012
    Location
    helsinki
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Squeezing more conditions into a sample SUMPRODUCT formula - show a novice pls!

    Quote Originally Posted by Richard Buttrey View Post
    Hi

    Yes a COUNTIFS() function would be infinitely preferable and with a big database far more efficient.

    See if the attached gives you some ideas. Note that I've added a helper column F to test whether at least one of columns A,B or C contains a value. The default standard for a COUNTIFS() function is the AND operator. So without a helper column you would need to add three COUNTIFS() together. i.e.

    =COUNTIFS()+COUNTIFS()+COUNTIFS()

    using columns A, B & C respectively in each one.


    Or of course if your layout lends itself a PivotTable as suggested by Miraun whilst I was typing!

    Hi Richard,

    Thanks again for your example with solutions.


    If you kindly have a look at the attacment with the simple table.

    If I am using the COUNTIFS function only, what could the formulas be for the following:

    1. Number of records where A is "F", B or C or D is not blank, and E date falls between start and end dates?
    2. Number of records where A is "M", B and C and D is blank and G or H date falls between start and end date?


    One more question please. Since I have dozens of combintations like these that I need to have for an expansive reports table (which is always used as it is - same data is always looked for), how could I work with the COUNTIFS function in terms of adding one condition next to the other e.g.

    COUNTIFS(range,criteria) when COUNTIFS(range,criteria) but not when COUNTIFS(range,criteria) etc. What signs are used for example "when" "and" "or" in the formula itself?

    Million thanks for your help.
    Attached Files Attached Files

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Squeezing more conditions into a sample SUMPRODUCT formula - show a novice pls!

    Hi,

    See attached

    In answer to your last Q. as I mentioned last time the default situation in a COUNTIFS() function is the AND condition. i.e. all criteria must be true or the count will be zero.

    If you need an OR condition to apply then you need to concatenate two or more Countifs together. i.e. =COUNTIF()+COUNTIF() so that if a criteria is not met in the first but is met in the second, you'll add a zero plus a count.

    You can see with your second question that although you have an OR condition with the G&H dates, that I have overcome this by using a helper column A to get a test date into a single column. This allows you to avoid using two (or more) COUNTIFA added together. I often prefer this technique of using a helper columns since it makes the formula smaller and easier to read.

    The signs are as in these example, i.e. the normal logical operators >, >=, <, <= <>
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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