+ Reply to Thread
Results 1 to 5 of 5

Logical expressions using array operations

  1. #1
    Registered User
    Join Date
    02-25-2013
    Location
    L.A
    MS-Off Ver
    Excel 2010
    Posts
    19

    Logical expressions using array operations

    Hi guys, I have a question regarding logical operations (Picture is attached)

    In cell F58 I entered: =OR(B58:B60>5,B58:B60<10) which outputs the correct logical answers.

    In cell E58 I entered: =(B58:B60>5)*(B58:B60<10) which outputs the correct binary logical answers.

    Now what I'm confused with is that if I enter =AND((B58:B60>5),(B58:B60<10)) in E58, it outputs FALSE, FALSE, FALSE in E58:E60. I am wondering why using the AND logical function does not work? (But using the OR function works?). The array multiplication equivalent of "AND" works though as shown in the picture.

    Breaking down the "=AND((B58:B60>5),(B58:B60<10))" formula I am not sure why it doesn't work, I understand the first condition (B58:B60>5) should output the set {FALSE, TRUE, TRUE} and (B58:B60<10) should output the set {TRUE, TRUE, FALSE} so AND({FALSE, TRUE, TRUE} , {TRUE, TRUE, FALSE}) should output {FALSE, TRUE, FALSE} if you just pair up each element, however excel does not output this, why is that? Is there a way to get AND to work using array operations?

    Also breaking down the "=OR(B58:B60>5,B58:B60<10)" formula, similarly, the first condition should generate {FALSE, TRUE, TRUE} and the second condition generates {TRUE, TRUE, FALSE}, so clearly if you match up each element then we get {TRUE, TRUE, TRUE} and excel does output that from F58:F60, how is it that AND doesn't work like this then?

    Thanks!
    Attached Images Attached Images
    Last edited by TrueTears; 02-26-2013 at 05:21 AM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Logical expressions using array operations

    it says returns true if all arguments =true or false if any argument is false
    so its doing what it says on the tin by design
    incidently
    normaly entered
    =AND(B1:B4>1,B1:B4<5) only actually uses b1 it ignores b2:b4
    however array entered {=AND(B1:B4>1,B1:B4<5)} considers all values B1:B4
    now OR
    =OR(B1:B4>1,B1:B4<5) this must always be true for a range of numbers if a number is greater1 it will give true if a number is less than 5 it will give true, any number fits one of those 2 criteria
    however
    =OR(B1:B4="y",B1:B4="n") again only b1 is tested unless array entered {=OR(B1:B4="y",B1:B4="n")}
    Last edited by martindwilson; 02-26-2013 at 05:52 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    02-25-2013
    Location
    L.A
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Logical expressions using array operations

    Quote Originally Posted by martindwilson View Post
    it says returns true if all arguments =true or false if any argument is false
    however array entered {=AND(B1:B4>1,B1:B4<5)} considers all values B1:B4
    Ohhh I see, thank you so much I understand it!

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Logical expressions using array operations

    I have marked this thread solved for you.
    In the future please select Thread Tools from the menu above and mark the thread as solved. Thanks.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    02-25-2013
    Location
    L.A
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Logical expressions using array operations

    Sorry about that, I'm new to the forums, I will take note of it 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