+ Reply to Thread
Results 1 to 8 of 8

Incorporating COUNTIF into SUMPRODUCT to eliminate a helper column

Hybrid View

  1. #1
    Registered User
    Join Date
    08-23-2018
    Location
    USA
    MS-Off Ver
    2013
    Posts
    6

    Incorporating COUNTIF into SUMPRODUCT to eliminate a helper column

    Please consider the following formula:

    =SUMPRODUCT((--(A1:A9="X")),(--(B1:B9=3)),(--(C1:C9=5)))

    It works as expected, and the formula in C1 is (copied into C2 to C9, as well):

    =COUNTIF(D1:H1,"Y")

    Is it possible to incorporate that COUNTIF formula into the SUMPRODUCT formula so I can eliminate helper column C? If so, how? Thanks!

  2. #2
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Incorporating COUNTIF into SUMPRODUCT to eliminate a helper column

    You need to provide more details.

    Which cell contains the SUMPRODUCT formula you show? Cell C1? If so, you'd get a Circular recalc warning because that formula refers to cell C1, so it's presumably not entered into any cell in A1:C9.

    Which cell contains the COUNTIF formula?

    Since Excel 2013 provides the COUNTIFS function, the SUMPRODUCT formula could be replaced by =COUNTIFS(A1:A9,"X",B1:B9,3,C1:C9,5).

    I'm guessing you want to combine the 3 vertical ranges A1:A9, B2:B9, C1:C9 with the horizontal range D1:H1. That may require SUMPRODUCT, maybe something like

    Formula: copy to clipboard
    =SUMPRODUCT((A1:A9="X")*(B1:B9=3)*(C1:C9=5)*(D1:H1="Y"))

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,675

    Re: Incorporating COUNTIF into SUMPRODUCT to eliminate a helper column

    May be:

    =SUMPRODUCT((A1:A9="X")*(B1:B9=3)*(MMULT(--(D1:H9="Y"),{1;1;1;1;1})=5))
    Quang PT

  4. #4
    Registered User
    Join Date
    08-23-2018
    Location
    USA
    MS-Off Ver
    2013
    Posts
    6

    Re: Incorporating COUNTIF into SUMPRODUCT to eliminate a helper column

    hrlngrv & bebo021999: Thank you both for the replies.

    I'm not able to upload a spreadsheet at the moment, so here is an example table (slightly different than my original post, but the basic intent is the same):


    -------A-----B-----C-----D-----E

    01_____X_____J_____Y_____Y_____Y
    02_____X_____K_____Y____________
    03_____X_____L_____Y_____Y_____Y
    04_____X_____J_____Y_____Y_____Y
    05___________L__________________
    06_____X_____L___________Y______
    07___________K_____Y_____Y_____Y
    08_____X_____J_____Y____________
    09_____X_____K_____Y___________Y
    10______________________________
    11______________________________
    12______________________________
    13_____J:____2__________________
    14_____K:____0__________________
    15_____L:____1__________________


    The inputs are in A1:E9, and the outputs are in B13, B14, and B15. B13 calculates the number of rows (A through E) that each meet all of the following conditions:

    • Has an X in column A
    • Has a J in column B
    • Has a Y in columns C, D, and E

    In this example, the formula in B13 equals 2, since only rows 1 and 4 meet all three of the above criteria. The formulas for B14 and B15 would be similar to B13, except they would be counting the number of "K" and "L" rows, respectively, that are fully complete (contains an X plus three Ys).

    Thus, I'm looking for a formula that would go in B13 (and B14 and B15). Suggestions?

  5. #5
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Incorporating COUNTIF into SUMPRODUCT to eliminate a helper column

    B13: =SUMPRODUCT((A1:A9="X")*(B1:B9="J")*(C1:E9="Y"))

    B14: =SUMPRODUCT((A1:A9="X")*(B1:B9="K")*(C1:E9="Y"))

    B15: =SUMPRODUCT((A1:A9="X")*(B1:B9="L")*(C1:E9="Y"))

    Or, given the labels in A13:A15,

    B13: =SUMPRODUCT((A$1:A$9="X")*(B$1:B$9=LEFT(TRIM(A13),1))*(C$1:E$9="Y"))

    with B13 filled down into B14:B15.

    Sorry, my mistake. You want all cols in C:E to be Y.

    B13: =SUMPRODUCT((A$1:A$9="X")*(B$1:B$9=LEFT(TRIM(A13),1))*(C$1:C$9="Y")*(D$1:D$9="Y")*(E$1:E$9="Y"))
    Last edited by hrlngrv; 09-21-2020 at 01:15 AM.

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

    Re: Incorporating COUNTIF into SUMPRODUCT to eliminate a helper column

    Hi All

    a very similar approach (please see Hringrv's post)

    =SUMPRODUCT(--(A1:A9&B1:B9&C1:C9&D1:D9&E1:E9="XJYYY"))

    =SUMPRODUCT(--(A1:A9&B1:B9&C1:C9&D1:D9&E1:E9="XKYYY"))

    =SUMPRODUCT(--(A1:A9&B1:B9&C1:C9&D1:D9&E1:E9="XLYYY"))

    Regards
    -----------------------------------------------------

    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.

  7. #7
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Incorporating COUNTIF into SUMPRODUCT to eliminate a helper column

    Data isn't always perfect. Sometimes not even good. What if C3 and D3 were blank but E3 contained YYY? If you're going to use mass concatenation, include separators.

    B13: =SUMPRODUCT(--(A1:A9&"|"&B1:B9&"|"&C1:C9&"|"&D1:D9&"|"&E1:E9="X|J|Y|Y|Y"))

    Let's just say I've spent a fair chunk of my career addressing that would never happen when it did.

  8. #8
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Incorporating COUNTIF into SUMPRODUCT to eliminate a helper column

    A13=J
    A14=K
    A15=L

    In B13 then copied down

    =SUMPRODUCT(($A$1:$A$9="X")*($B$1:$B$9=$A13)*($C$1:$C$9="Y")*($D$1:$D$9="Y")*($E$1:$E$9="y"))
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

+ 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] Using SUMPRODUCT/ARRAY formula instead of helper column
    By esbencito in forum Excel General
    Replies: 6
    Last Post: 01-23-2018, 10:22 PM
  2. [SOLVED] Eliminate Blanks in a Column using Helper Column
    By majime01 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-12-2017, 04:03 PM
  3. Sort by helper column even if values in helper are alike
    By NoSleepForMe in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-10-2016, 04:14 AM
  4. Pivot table help, incorporating SUMPRODUCT
    By Udaman in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-13-2016, 04:44 PM
  5. [SOLVED] Incorporating a CountIF function into VBA
    By jbumps in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-14-2012, 06:21 PM
  6. Alternative for a CountIF which using a Helper Column?
    By e4excel in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-11-2012, 03:25 AM
  7. Modify Sumproduct to include helper column
    By JDarling in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-17-2007, 06:03 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