Return an array of True/False based on two columns meeting a criteria - excel

I would like to adjust the following CSE formula to return an array of Booleans for each row should the criteria in columns A and B be met. The statement below is acting as an OR function currently.
= (A:A="Y")+(B:B="Y")
E.g.if I have two columns as follows I'd like a third column C with the formula to return as follows:
A B C
Y N {False,False,True}
N Y {False,False,True}
Y Y {False,False,True}
The formula above currently returns:
A B C
Y N {True,True,True}
N Y {True,True,True}
Y Y {True,True,True}

Use the TRANSPOSE() function: =TRANSPOSE(((A:A="Y")+(B:B="Y"))=2)
The CSE formula =(A:A="Y")+(B:B="Y") will return a tall array: {FALSE;FALSE;TRUE}. {FALSE,FALSE,TRUE} is a long array. TRANSPOSE will convert tall to long and vice-versa.

Related

Count number of X in Column A when Y is in either Column B or C

Simplified data in columns A, B and C:
A | B | C
X | | Y
| Y |
X | Y |
Z | | Y
X | |
How to count the number of X when the value of Y is present in column B or C?
(ie. result is 2). Was thinking about COUNTIFS but can't seem to get the formula right :(
You can't do this with a single COUNTIFS, because conditions in COUNTIFS are AND, not OR. You can do it with multiple COUNTIFS, or an Array Formula (not recommended - that's a bit overkill for this case)
You need to count up all the rows where Column A is X and Column B is Y, add all the rows where Column A is X and Column C is Y, and then decide of a row where Column A is X and both Column B and Column C are Y is possible and/or should be counted twice.
If it is possible, but should not be double-counted, then you will need to subtract all the rows where Column A is X and Columns B and C are both Y.
=COUNTIFS($A:$A,"X",$B:$B,"Y") + COUNTIFS($A:$A,"X",$C:$C,"Y") - COUNTIFS($A:$A,"X",$B:$B,"Y"",$C:$C,"Y")
If it can't be in both, or you want that to count as 2 rows instead of 1, then you don't need the third COUNTIFS
As an Array Formula (using SUMPRODUCT instead of SUM, because then we don't need to use Ctrl+Shift+Enter), for reference:
=SUMPRODUCT(--($A:$A="X")*--(--($B:$B="Y")+($C:$C="Y")>0))
(The >0 is so that the OR (+) doesn't double-count)
Because you never have a double-Y case, you can use:
=SUMPRODUCT((A1:A5="X")*(B1:B5="Y"))+SUMPRODUCT((A1:A5="X")*(C1:C5="Y"))

EXCEL counting empty rows

A B C D E F G H
1 Y Y Y X
2 X X
3 Y Y
4 X X
5 Y Y Y X
Count the number of empty rows (from Columns A to E) and put result here. Answer should be 2 from example above.
Hi Folks,
I'm struggling to find the correct Excel formula to count the number of rows with no data from columns A through E, and putting that answer in a cell. These 'empty rows' may have data in later columns (like F, G, H), but I just want to count the rows with no data from columns A to E.
Any help would be appreciated.
Since array formulas tend to confuse people, here's a non-Array formula approach:
Place =IF(COUNTA(A1:E1)=0,1,0) into row 1 of (for example) column I and drag down to row 5. Then place a sum formula below that to get the answer, for example: =SUM(I1:I5)
Try this array formula,
=SUM(IF(ROW(1:5), IF(A1:A5&B1:B5&C1:C5&D1:D5&E1:E5="", 1)))
Remember to finalize with ctrl+shift+enter, not just enter.
You could also use a variation on the standard formula for getting row sums of a 2d array
=SUM(N(MMULT(N(A1:E5=""),TRANSPOSE(COLUMN(A1:E5)^0))=COLUMNS(A1:E5)))
or
=SUM(N(MMULT(N(A1:E5="Y"),TRANSPOSE(COLUMN(A1:E5)^0))=0))
Again they are array formulas and have to be entered with CtrlShiftEnter

Compare values from multiple columns

I'm trying to compare values from multiple columns and then highlight the row if it matches my criteria using conditional formatting. For example: in the table below, there are four columns, and I want to compare the values within the the 3 columns: A-C. If they all match, then I want to highlight the entire row. When I use conditional formatting, I'm only able to compare two of the three. I don't know the syntax to compare more than columns.
A B C
Name Has Dog Has Cat Has Bird
A Y Y Y
B Y N Y
C Y Y N
D N N Y
E Y Y N
Please try:
=AND($B1=$C1,$B1=$D1)
for Format values where this formula is true: and Applies to all the columns you have available.

Excel Array Function to Sum a number of COUNTIF statements

I'm having difficulty phrasing this intelligently, but I'll try the long way -- I need a function that assigns a 1 or 0 depending on whether the row has an "x" in one of four previous columns and then sums all those assigned values.
In other words, imagine the following formula is in E2 and autofills down for any given number of rows.
=IF(COUNTIF(A2:D2, "x")>=1, 1, 0))
I want to write an array function in F2 that would do the equivalent of summing all the values in column E (but don't reference column E).
Sum of ...
=IF(COUNTIF(A2:D2, "x")>=1, 1, 0))
=IF(COUNTIF(A3:D3, "x")>=1, 1, 0))
=IF(COUNTIF(A4:D4, "x")>=1, 1, 0))
=IF(COUNTIF(A5:D5, "x")>=1, 1, 0))
...for all of column A through D
Sample Data:
A B C D
20-Sep 20-Sep 21-Sep 21-Sep
x x
x x
x
x
x
x
x
x x
x
The formula should return the value 9. There are 9 rows that have an "x" between the columns A and D.
Try this out:
=SUM(--(MMULT(--(A2:D5="x"),{1;1;1;1})>0))
Commit normally (array entry will neither help nor hurt). If your production range is wider than 4 columns expand the {1;1;1;1} array.
Also works:
=SUM(N(MMULT(N(A2:D5="x"),{1;1;1;1})>0))

Return value of last populated cell in variable range

Into column D, I'd like to copy the value from the last cell with data in columns E up until the column with the header "DETAIL". There might be anywhere from 2 to 15 columns from E until the column with that header, so that's where I'm stuck. So to be clear, an example:
A B C D E F G H DETAIL
1 x x x a b c d x
2 x x x x
3 x x x c b a x
3 x x x d c x
Should fill column D like so:
A B C D E F G H DETAIL
1 x x x d a b c d x
2 x x x x
3 x x x a c b a x
3 x x x c d c x
I don't mind handling this with a formula (which I couldn't come up with) or programmatically.
Create a dynamic named range by pressing CtrlF3 to bring up the Name Manager, click New, name the range something (I chose MyRange) and then use this formula to define it (Note you may need to change the Sheet name):
=Sheet1!E2:INDEX(Sheet1!2:2,MATCH("Detail",Sheet1!$1:$1,0)-1)
Then, in cell D2 and copied down, use this formula (I did not use IFERROR so that it would be backwards compatible):
=IF(COUNTA(MyRange),INDEX(MyRange,MATCH(REPT("z",255),MyRange)),"")
Here are the results (highlighted) using your provided sample data:
Please try:
=IFERROR(INDEX(F2:T2,,MATCH("zzzzzz",F2:T2)),"")
in D2 and copied down to suit.
Try using LOOKUP:
=IFERROR(LOOKUP(9^99,SEARCH("*",E1:H1),E1:H1),"")
SEARCH("*",E1:H1) returns a number when it matches any character and an error when the cell is blank. LOOKUP then returns the contents of the cells of the last number smaller than 9^99 in the array generated by SEARCH.
For example, in the first row, SEARCH("*",E1:H1) returns {1,1,1,1} so that LOOKUP returns the last 1, being d.
In the third row, SEARCH("*",E3:H3) returns {1, 1, 1, #VALUE!} and LOOKUP returns the last 1, which is a here.
This formula will work with numbers and text alike. The downside is that it is considered slower than INDEX/MATCH. On the other hand, you can modify the INDEX/MATCH to work with numbers, or modify it to work for both but becomes an array formula:
=IFERROR(INDEX(E1:H1,,MATCH(1,SEARCH("*",E1:H1))),"")
[Works with Ctrl+Shift+Enter, otherwise returns an empty cell with Enter alone]

Resources