+ Reply to Thread
Results 1 to 11 of 11

joint regions problem...

  1. #1
    Registered User
    Join Date
    10-16-2008
    Location
    iowa
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    63

    joint regions problem...

    I have two vertical row ranges, and want to combine them in a formula. The old range was "data", the new is a combination of two ("Feb_11", "Jun_11") - the two regions are all rows, and contiguous, and a subset of the old "data" region.

    It works fine in most formulae, but fails in a count usage; Is this just another Excel anomaly, or am I doing something wrong?

    I've tried parenthesizing it in various ways, which should not be required, but still didn't help.

    Thanks.

    Works:
    =AVERAGE(AZ:AZ ) [old]
    =COUNTIF(AZ:AZ data, ">="&(AY162*(AZ:AZ Total))) [old]

    =AVERAGE(AZ:AZ (Feb_11,Jun_11)) [new]

    Fails: (#Value)
    =COUNTIF(AZ:AZ (Feb_11,Jun_11), ">="&(AY162*(AZ:AZ Total))) [new]

    If I evaluate the two ranges separately, ti works fine.
    =COUNTIF(AZ:AZ Feb_11, ">="&(AY162*(AZ:AZ Total)))
    +COUNTIF(AZ:AZ Jun_11, ">="&(AY162*(AZ:AZ Total)))

    Oddly(?) enough, if I define a new name:
    Group1 = Feb_11,Jun_11

    Then all the arithmetic formluae work find on it, but still the Count fails in the same way.
    Last edited by guthrie; 09-24-2011 at 04:07 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: joint regions problem...

    COUNTIF, unlike AVERAGE, requires a single contiguous range. For this reason the aggregation of 2 separate COUNTIFs works without issue and your attempt at using both ranges in a single COUNTIF does not.

    I confess I am unclear as to why you are using an Intersect approach in your references ? I suspect your AZ references are superfluous.

  3. #3
    Registered User
    Join Date
    10-16-2008
    Location
    iowa
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    63

    Re: joint regions problem...

    Thanks, this is what I suspected, and what the experiments show.

    I have run into this before, where an Excel function says it operates on regions, but in fact requires a single monolithic region definition. Even equivalent definitions of contiguous regions fail. The definition of the function does not say anything about this, nor the error message - and it is one of a class of Excel errors that to me are illogical, undocumented, and have poor error messages, all leading to creating a big time waste to figure out and then circumvent.

    If the error at least said "cannot use multiple composite region definitions with this function" that would be more reasonable, but even then, seems odd and restrictive to have this restriction in the underlying semantics.

    Is there a list of what functions have this type of limitation?

    Do VBA Region usages have the same limitations? (Not that I want to have to convert to using VBA for such simple things.

    I need Intersect because Data is selection of rows, and each column queries it. Without the AZ:AZ the sum (for example) would sum the entire data region.

    Thanks again for the clarification.

  4. #4
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: joint regions problem...

    Do you have XL2007 or later? Countifs function will do what you need, as will sumproduct or DonkeyOte said combine 2 countif
    Windows 7 using Office 2007 & 2010

    Remember your [ code ] [ /code ] tags, makes reading soooo much easier

  5. #5
    Registered User
    Join Date
    10-16-2008
    Location
    iowa
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    63

    Re: joint regions problem...

    Yes, Excel 2010. And Countif fails as above.

    And yes, I did revert to multiple ones to get around this limitation.

    To me this is a bug - a described and logical usage of a builtin function fail, and in a very generic and non-descriptive manner. But, it's been in Excel for decades, so ... :-)

  6. #6
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: joint regions problem...

    Quote Originally Posted by guthrie View Post
    Yes, Excel 2010. And Countif fails as above.

    And yes, I did revert to multiple ones to get around this limitation.

    To me this is a bug - a described and logical usage of a builtin function fail, and in a very generic and non-descriptive manner. But, it's been in Excel for decades, so ... :-)
    Countif is what you used in your sample, does Countifs work?

    Countifs will let you add more than one range and criteria where as countif stalls at one range and one criteria

  7. #7
    Registered User
    Join Date
    10-16-2008
    Location
    iowa
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    63

    Smile Re: joint regions problem...

    Ah, thanks - I mis-parsed your "s" in countifs...

    This works;
    If I evaluate the two ranges separately, ti works fine.
    =COUNTIF(AZ:AZ Feb_11, ">="&(AY162*(AZ:AZ Total)))
    +COUNTIF(AZ:AZ Jun_11, ">="&(AY162*(AZ:AZ Total)))

    this fails:
    =COUNTIFS(AZ:AZ Feb_11, ">="&(AY162*(AZ:AZ Total)),
    AZ:AZ Jun_11, ">="&(AY162*(AZ:AZ Total)) )

    ?? :-)

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: joint regions problem...

    COUNTIFS is not applicable here (it is an AND based test and does not circumvent the main issue). You should aggregate your separate COUNTIF tests as previously outlined.

    Regards use of entire rows and Intersect - this makes sense - thanks for the clarification.

  9. #9
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: joint regions problem...

    Can you break your code down? Whats in (AZ:AZ Feb_11) thats not in (AZ:AZ Total)? i'm guessing this is on the same sheet?

    And what is this referring to? (AY162*(AZ:AZ Total) could you upload a sample......I'm a little confuesd at your syntax

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: joint regions problem...

    @scottylad2,

    Please Login or Register  to view this content.
    for example uses the Intersect of Column AZ and Feb_11 Named Range.

    The issue here is that OP wants to apply the same criteria to two separate ranges in a single COUNTIF - this is not possible for those reasons outlined previously.

  11. #11
    Registered User
    Join Date
    10-16-2008
    Location
    iowa
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    63

    Re: joint regions problem...

    Yep - thanks , I get it now, and will use the countif per region approach.
    And - hope that Excel will generalize the usage in the future. :-)

+ 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