Excel - check multiple true/false conditions - excel

I have three cells which can either contain TRUE or FALSE. Then in another cell use a formula to check that only one cell contains true. If multiple of these cells are true, than I want to display an error message.
F4,G4 and H4 is where the values are written:
F4: True or False
G4: True or False
H4: True or False
Then in D4 I need to make my check. At the moment I can only figure out how to check if one of two fields contains true/true:
=IF(AND(F4=TRUE;G4=TRUE);"Only one true value allowed!";"Success!")
Is it possible to extend above function to check whether all three cells contains one TRUE value?

An alternative:
=SIGN(F4)+SIGN(G4)+SIGN(H4)=1

You can use countif to check how many cells contain True, and use an if statement to return a message depending on that value.
In cell D4 use this formula:
=IF(COUNTIF(F4:H4,"True")>1,"Only one true value allowed!","Success!")
As mentioned in the comments the formula would not chek for all three acounts being false, here is an update to the formula to correct the issue:
=IF(COUNTIF(F4:H4,"True")>1,"Only one true value allowed!",IF(COUNTIF(F4:H4,"True")<1,"Only one true value allowed!","Success!"))
And to add to that we can add a countblank to make sure all cells contain some data:
=IF(COUNTIF(F4:H4,"True")>1,"Only one true value allowed!",IF(COUNTIF(F4:H4,"True")<1,"Only one true value allowed!",IF(COUNTBLANK(F4:H4)>0,"Only one true value allowed!","Success!")))
further changes could be made to make sure only true or false are within each cell.

Related

Counting TRUE for Values obtained from if function

I have applied if formula to display TRUE or False when condition is TRUE and false respectively. However, the count formula is unable to count the number of Trues obtained from the aforementioned formula even when I reference the cell with the value TRUE or use direct reference as "TRUE" in the formula. Can anyone tell me why this is happening and how to reference the value of TRUE to countif?

In Excel, why do Boolean values return different results than a Boolean formula?

I was trying to extract unique data from a list and I came across something strange. Below you'll find a screenshot with the translated formulas next to the cells (because my Excel isn't in English).
This is 3 times the same schedule, with only one change in cell B5.
Since COUNTIF($B$1:B4;$A$2:$A$9)=0 is a Boolean formula, this should return either TRUE or FALSE, no other options. So I changed it once to TRUE and once to FALSE.
But when I change it to TRUE, the result changes from h45 to h3, and when I change is to FALSE, the result changes to #DIV/0 (as expected).
How is it possible that TRUE returns h3 yet COUNTIF($B$1:B4;$A$2:$A$9)=0, which is TRUE, returns h45?
EDIT: I just noticed I forgot to change $A$2:$A$9 at the end of the formulas, but since the data isn't changed this really doesn't matter.

Excel Reverse Match

I'm trying to find a way to do a reverse match in Excel. I have a column of TRUE/FALSE statements and I need to find a way to find both a match and a reverse match within this one column to find the difference between TRUE statements in both directions.
True
False
False
False
True
False
False
True
In this scenario from the perspective of the middle True statement the normal MATCH function going down would return a number of 4. I am trying to find an additional match function that would look upward to the TRUE statement and return a value of 5
Quick and dirty:
A1:A7: TRUE/FALSE
A8: Array formula: {=LARGE(IF(A1:A7=TRUE;ROW(A1:A7);"");1)}
The result will be the row number of the nearest TRUE from below.
The formula is inserted by Shift-Ctrl-Enter in a formula window. Curled brackets are inserted by Excel, not by a user.
If you need the shift from the last TRUE:
{=LARGE(IF(A1:A7=TRUE;ROW(A1:A7);"");2)}
Changing the last number in the formula moves you to the n-th TRUE from below.
Replacing LARGE with SMALL will give the row numbers from above. So it would possible to find the shift between relevant combinations by combining the formulae.

Identify a subset of a range using TRUE statements

I am attempting to identify a subset of a range based on TRUE FALSE statements. An example is in the following chart below.
FALSE FALSE 1.21147
TRUE FALSE 1.20984
FALSE FALSE 1.21083
FALSE FALSE 1.210315
FALSE TRUE 1.21151
FALSE FALSE 1.21335
FALSE FALSE 1.213515
FALSE FALSE 1.212435
TRUE FALSE 1.212125
FALSE FALSE 1.21226
In this scenario I want a subset to be identified based on alternating TRUE statements. In the left side column the first TRUE statement would trigger the beginning of the subset an the TRUE statement in the second column would trigger the end of the subset. I then want to use a simple max function to identify the MAX in the third column. I would use an IF statement to determine whether or not the first TRUE statement is correct however, i am unable to figure out how to identify the subset of the range based on the TRUE statement in the second column. I also want to know whether or not this works from going from the top to the bottom if the statement could possible work going the bottom to the top. Any help would be most appreciated.
Part 1 can be done using a combination of MATCH, OFFSET and MAX
For this example I've assumed your data is located starting at cell A2.
For the sake of clarity I use some intermediate results in cells E1:E4. If you prefer a single formula, simply merge the intermediate formula into the final formula
Cell E2 = position of first TRUE in column A
=MATCH(TRUE,A2:A11,0)
Cell E3 = position of first TRUE in column B
=MATCH(TRUE,B2:B11,0)
Result formula, Max value in column C between the rows found in E2 and E3 (inclusive)
=MAX(OFFSET($C$1,E2,0,E3-E2+1,1))
Part 2 is more tricky: I don't think you can search up a range for a value. However, looking at your data it may be OK to search down for the second TRUE? If this is OK then:
Cell E4 = position of second TRUE in column A
=MATCH(TRUE,OFFSET(A2:A11,E2,0),0)
Or this, entered as an array formula (Insipred by Barry) which will get the last TRUE in the column
=MATCH(2, 1/(A2:A11=TRUE),1)
Result formula, Max value in column C between the rows found in E3 and E4 (inclusive)
=MAX(OFFSET($C$1,E3,0,E4+E2-E3+1,1))
your part about traversing the table from the bottom up confused me, and also don't know if you can have more than one subset, since you're penultimate row seems to be the opening of a new subset that is not closed. Anyway, hope that this helps. I'm assuming you don't want to use macros, in which case it would be trivial. What you can do is pad the top of the data set with an row that contains FALSE, FALSE, 0, 0, and add this formula to a fourth column starting with the first row of your set:
=IF(AND(NOT(A2),NOT(B2),OR(D1=0,AND(NOT(A1),B1))),0,C1)
That's assuming that your first row is row 2, and row 1 is used for the padding. A, B, and C are the three columns in your example, and D will print the value of the third column if it's within a subset, or zero if is not, so that you can easily calculate max() or whatever you want to do. I looks like this:

Using the Concatenate function in an IF statement

I am trying to find a string in excel cells, and it works to some extent, but when the value returns false I simply get "FALSE" in the cell, although when it returns a true value it actually changes the cell to what I have defined in the IF statement.
Is this because I have inserted the concatenate query incorrectly in the if statement?
My formula is as follows:
=IF(ISNUMBER(SEARCH(ET2:ET4,B2)),"yes",F2=CONCATENATE("NA ",B2))
The reason you get false is the bit that says
F2=CONCATENATE("NA ",B2)
I think you're trying to use this as an assignment (ie set the cell F2 to the value of the ConCat).
What it will actually do is compare the value of F2 and the value of the concat, and return TRUE if they are equal and FALSE otherwise. This TRUE or FALSE value is what you are ending up with in your cell.
So to fix it:
If the above formula is in the cell F2, then just remove the F2= from the formula and it should work.
If the above formula not in the cell F2, then you need to put either this same formula or a slightly altered one into that cell to populate F2.

Resources