+ Reply to Thread
Results 1 to 6 of 6

Shorten a Countif/Sumproduct formula

  1. #1
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Shorten a Countif/Sumproduct formula

    Hi, I have a formula, that I feel like should be shorter:

    =COUNTIFS(INDIRECT("Data!B2:B100000"),">"&EndLastYear,INDIRECT("Data!B2:B100000"),"<="&ThisMonth,INDIRECT("Data!J2:J100000"),"Value A")+COUNTIFS(INDIRECT("Data!B2:B100000"),">"&EndLastYear,INDIRECT("Data!B2:B100000"),"<="&ThisMonth,INDIRECT("Data!J2:J100000"),"Value B")+COUNTIFS(INDIRECT("Data!B2:B100000"),">"&EndLastYear,INDIRECT("Data!B2:B100000"),"<="&ThisMonth,INDIRECT("Data!J2:J100000"),"Value B")

    I was trying to use a sumproduct, somewhere, but couldn't seem to figure it out. Any help would be awesome! (Also, would there be a way to have a named range for the list of "Values"?)

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Shorten a Countif/Sumproduct formula

    I can't see why you're using INDIRECT there, and it will just slow the workbook down?

    Anyway, you could use something like this:

    =SUMPRODUCT(COUNTIFS(INDIRECT("Data!B2:B100000"),">"&EndLastYear,INDIRECT("Data!B2:B100000"),"<="&ThisMonth,INDIRECT("Data!J2:J100000"),A1:A50))

    replace the blue part with a range containing the values you want.
    Rory

  3. #3
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Shorten a Countif/Sumproduct formula

    Thanks, I'll give it a try. Sorry about the indirects (they're a result of overwriting data w/ vba, causing my formulas to disappear)

    *worked perfectly. Thanks again!

  4. #4
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Shorten a Countif/Sumproduct formula

    I need to follow up on this formula, because it's working; sort of.

    Please forgive me for not providing a sample workbook, I hope this is clear enough

    I've added one other set of possible criteria to the end of the formula:

    =SUMPRODUCT(COUNTIFS(INDIRECT("Data!B2:B100000"),">="&BeginningThisYear,INDIRECT("Data!B2:B100000"),"<"&NextMonth,INDIRECT("Data!J2:J100000"),InjuryTypes,INDIRECT("Data!Z2:Z100000"),SalesMarketing))

    The name SalesMarketing consists of several different items, and should return 13, yet I'm only getting 2 in response. I've been racking my brain and nothing's making sense.


    Here's another example, and I can be a bit more specific I think:

    Main should show 18, not 15. The named range "GroupABC" consists of {"Group A"; "Group B"; "Group C"}

    When I use the formulas individually, the results come back proper, (12, 5, 1), as below, but when I use the named range it just doesn't work.






    Main - 15 =SUMPRODUCT(COUNTIFS(INDIRECT("Data!B2:B100000"),">="&BeginningThisYear,INDIRECT("Data!B2:B100000"),"<"&NextMonth,INDIRECT("Data!J2:J100000"),InjuryTypes,INDIRECT("Data!Z2:Z100000"),GroupABC))

    Group A - 12 - =SUMPRODUCT(COUNTIFS(INDIRECT("Data!B2:B100000"),">="&BeginningThisYear,INDIRECT("Data!B2:B100000"),"<"&NextMonth,INDIRECT("Data!J2:J100000"),InjuryTypes,INDIRECT("Data!Z2:Z100000"),"Group A"))

    Group B - 5 - =SUMPRODUCT(COUNTIFS(INDIRECT("Data!B2:B100000"),">="&BeginningThisYear,INDIRECT("Data!B2:B100000"),"<"&NextMonth,INDIRECT("Data!J2:J100000"),InjuryTypes,INDIRECT("Data!Z2:Z100000"),"Group B"))

    Group C - 1 - =SUMPRODUCT(COUNTIFS(INDIRECT("Data!B2:B100000"),">="&BeginningThisYear,INDIRECT("Data!B2:B100000"),"<"&NextMonth,INDIRECT("Data!J2:J100000"),InjuryTypes,INDIRECT("Data!Z2:Z100000"),"Group C"))

  5. #5
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Shorten a Countif/Sumproduct formula

    Furthermore, when I evaluate the formula for Main, as shown above, the final result it shows me is 11, 4, 0 (as if each result is accurate minus 1), Very very strange.

  6. #6
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Shorten a Countif/Sumproduct formula

    I found on a website:https://stackoverflow.com/questions/...e-named-ranges


    That if I use Transpose in an ARRAY formula it does the trick, but I wouldn't call this ideal, if possible.. Here's the formula I ended up with

    {=SUM(COUNTIFS(INDIRECT("Data!B2:B100000"),">="&BeginningThisYear,INDIRECT("Data!B2:B100000"),"<"&NextMonth,INDIRECT("Data!J2:J100000"),InjuryTypes,INDIRECT("Data!Z2:Z100000"),TRANSPOSE(GROUPABC)))}

+ 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 require to insert countif function and shorten the formula
    By mso3 in forum Excel Formulas & Functions
    Replies: 29
    Last Post: 07-18-2014, 09:59 PM
  2. [SOLVED] COUNTIF embedded in a SUMPRODUCT formula
    By macrorookie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-11-2014, 09:02 AM
  3. Proper syntax to shorten Countif formula
    By small_wonder in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-01-2012, 09:23 AM
  4. [SOLVED] Can you help shorten this sumproduct formula?
    By lorne17 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-15-2012, 07:09 PM
  5. How to shorten the formula - IF(SUM(COUNTIF(
    By fang603 in forum Excel General
    Replies: 2
    Last Post: 03-09-2012, 08:59 AM
  6. Formula Help: Countif or Sumproduct
    By 1979excelhelp in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-19-2011, 04:02 PM
  7. SUMPRODUCT formula with COUNTIF not working
    By Trueman_86 in forum Excel General
    Replies: 2
    Last Post: 07-15-2010, 06:58 AM

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