Check for two out of three conditions (Homework)

Excel Challenges - 72 comments

Time for some logic check.

Suppose, you have three logic values in A1:C1 (TRUE or FALSE values in each cell)

You need to find out if ONLY two of these values are TRUE.


How would you write the formula?

Got an answer? Awesome. Just post your formula in the comments. Let’s see how much variety we can get from all of our readers.

Bonus question: Let’s say you have a list A1:C100, each row containing outcome of three conditions. How do you find out the total number of rows where ONLY two out of three conditions are met.

Go ahead and post your answers.

Related: XOR formula in Excel | Summing up neither A nor B values.


Hello Awesome...

My name is Chandoo. Thanks for dropping by. My mission is to make you awesome in Excel & your work. I live in Wellington, New Zealand. When I am not F9ing my formulas, I cycle, cook or play lego with my kids. Know more about me.

I hope you enjoyed this article. Visit Excel for Beginner or Advanced Excel pages to learn more or join my online video class to master Excel.

Thank you and see you around.

Related articles:

Written by Chandoo
Tags: , , , ,
Home: Chandoo.org Main Page
? Doubt: Ask an Excel Question

72 Responses to “Check for two out of three conditions (Homework)”

  1. MF says:

    Here's my attempt:

    Only two trues

    Total number of 2 trues

    • jomili says:

      Curious: if I put in A1 + B1 +C1, I get 2 for the answer, but if I put in Sum(A1:C1) I get 0. Why does SUM work differently?

      • jomili says:

        Found my own answer in the documentation on the SUM function:

        If an argument is an array or reference, only numbers in that array or reference are counted. Empty cells, logical values, or text in the array or reference are ignored.

        But we could do this:

  2. TheQ47 says:

    In Column E, the following formula:

    Total No of TRUEs:

  3. Amol says:


  4. ab says:


  5. Eric says:

    For the first part (i.e., return TRUE if 2 of 3 are TRUE:


    The easy way for the second part is to put the above formula in D1 and copy down, then put this in E1


    MF's way for part 2 is the single cell (no copy down) answer.

  6. Richard Charrington says:

    Simpler than that:


  7. Richard Charrington says:

    Simpler still, as MF says:


  8. Alex says:

    This one is for who does not how to use SUMPRODUCT:


    Bonus question:

  9. Bra?o Kollár says:

    Answer to main question: "=SUMPRODUCT(--$A2:$C2)=2"

  10. John Jairo V says:

    Hi to all!

    Check if two conditions are true:
    =A1+B1+C1=2 (like MF)

    Get Total number of rows with two conditions met:


    • jomili says:

      I see you and Ola used the same MMULT formula. I'm trying it in my worksheet and getting a #VALUE error. My range of TRUE or FALSE is A5:C100, so the formula I'm using is

      I'm NOT CSE entering it (though I tried that too). Any ideas why I'd get the Value error?

    • Sean Hodkinson says:

      John Jairo, thank you for this great MMULT formula, I spent 3 hours this evening figuring out how to use it, should come in handy in future.

  11. Ola says:

    Ah, same conclusion:)
    Whole matrix: =SUM(N(MMULT(--A5:C11;{1;1;1})=2))
    Row by row: =IFERROR(1/((A6+B6+C6)=2);"")

  12. Mehmet Gunal OLCER says:


  13. Juan says:


  14. Juan says:


    Sorry, fail if 3 trues

  15. Juan says:


    This is valid

  16. Juan says:

    Forgive me..
    Is not my day...

  17. Stupid Juan says:




  18. Nagaraj says:


  19. Jason Morin says:

    Answer: =SUMPRODUCT(--A1:C1)=2

    Bonus: =SUM(IF(MMULT(IF(A1:C100=TRUE,1,0),{1;1;1})=2,1,))

  20. Guy S says:


  21. ZORRO2005 says:

    array formulas:

  22. ZORRO2005 says:


  23. ZORRO2005 says:


  24. Jack says:

    I did:


    Then if you don't have TRUE or FALSE in those cells but you want to find a particular entry instead:


    Range can be extended as far as you like and you can manipulate the =2 to say >3 or <=20 depending on how many TRUEs you want to find

  25. Xiq says:

    It is of course all in binary, so binary compensation it is! 😉



  26. Ed B says:

    Here is my attempt:


    I have to give more thought to the bonus question!

  27. deesloop says:

    First post 🙂

    Manipulating as a string is an unpleasant way of doing it m


  28. deesloop says:

    Or just falses


  29. Hinck says:

    if values in range A1:C1 then {=SUM(A1:C1*{TRUE,TRUE,TRUE})=2} works fine. Gives true/false result

  30. ZORRO2005 says:

    array formula

  31. ZORRO2005 says:


  32. Bhavani Seetal says:

    Hi All,
    A1 B1 C1 LOGIC
    TRUE TRUE FALSE Any 2 Values are True
    TRUE TRUE FALSE Any 2 Values are True
    =IF(COUNTIF(A2:C2,TRUE)=2,"Any 2 Values are True","-")

  33. govind says:

    Hi Chandoo

    i have been looking for some solution on margin % bridge and tried lot of searches but could not succeed, was hoping if you could provide me some solution, below is the problem, if i want to map the movement in margin% from one period to another in terms of contribnution from price, volume, cost changes, what is solution

    Margin in 2015 10%
    Margin in 2016 12%

    how these 2% movement can be broken into price variance, volume and cost mix variance.

  34. Chirayu says:


  35. mark says:


    for total number of rows with exactly 2 TRUE values, just sum the formulas, or, more simply, another array formula

  36. SK says:


  37. Sagar Malik says:


  38. Sagar Malik says:


    • Sagar Malik says:

      correct range and removing the redundant true comparison


  39. Jomili says:

    Just a comment that most of these responses check whether there are two trues in the range, whereas the post title is "Check for two out of three conditions ", so instead of True/Falses the data should be other values. For instance "Bill, Tom, Bill" would be true, "Bill, Tom, Mary" would be false. I'd like to see some solutions for that type of problem.

    • Robert says:

      Great complication to this problem! How about:


      I love all the posts in here - always amazes me how many solutions to the problem there are (and mine usually ends up being way to complicated).

      • Jomili says:

        You rock! I thought David Hager's CSE formula was going to be the only that would work, then you go ahead and do it with a simple (though it LOOKS complicated) formula. Way to go!

        • Jomili says:

          So, applying Robert's solution to the grid below (sorry, this application doesn't allow me to paste very well), I show 8 rows have 2 values that have 2 out of 3 conditions the same. Robert's formula will show the rows that match on a row by row basis, but going to Chandoo's Bonus question, How do you find out the total number of rows where ONLY two out of three conditions are the same?

          TRUE FALSE Blue
          Ted Bill Ted
          Mary Tom Mary
          Ted Bill Ted
          Mary Bill Ted

          • Chandoo says:

            You can try this.


          • Jomili says:

            You're a wizard! That appears to work wonderfully! But now you're going to force me into learning more about Sumproduct, one formula I've never truly understood. Thanks!

          • ZORRO2005 says:


    • Chandoo says:

      Good solutions Robert & David.

      I suggest this

      =(a1=b1)+(b1=c1)+(c1=a1) = 1

  40. David Hager says:


    • Jomili says:

      I had to CSE it to get it to work, but it DOES work fine, gives TRUE if any two of three values are the same. I think Chandoo should give you the prize!

  41. Vinu says:

    Has anybody tried =AND(NOT(XOR(A1:C1)),OR(A1:C1)) ?
    Worked for me

    Seems like this would work for checking for a majority TRUE in any length array...

  42. jomili says:


    I can't get your formula to work. Walking through it, it looks like "A1:C100" doesn't resolve to a value (gives VALUE error), which is hosing the formula.

  43. jomili says:

    Okay, I figured it out:
    1) Have to enter it as array (CSE)
    2) If my values don't start in A1:C1, but instead in A10:C10 through A19:C19, have to change the formula like so:
    Appears to work fine. Thanks!

  44. Sadanandan says:

    I want a formula ie. If a1=1 and b1 should be equal to c1 and if a1 is 2 b1 should be equal to d1

  45. Pixy says:

    The problem is if you do not have numbers. Thats why I think I need logical formula.
    What about this?

  46. Ashok says:

    i want to check whether a number is in range a1:e1. suppose if that number is in cell c1, i want to find the largest number in range c1:c10. wats the formula in excel

Leave a Reply

« »