It seemed simpler to put the conditions in a range (named TestR) and then use:
=if(or(iserror(match(C3,TestR,0)),A3<>"X"),"No","Yes")
I have opted for a shorter formula, mainly by hiving off the four ‘list’ items into a named range. Rather than mix AND and OR I opted for just OR by testing for all the possibilities that should give rise to a “No” result. These are that the ColumnC value is not in the list (by trying to match it to the list and failing) as one possibility and that the ColumnA value is not “X” as the other possibility. Otherwise “Yes” should be returned.
The formula you tried has at its core a long OR function. The syntax for this is valid, the problem is with the logic. OR will return TRUE
if any of its tests return true, provided none of them returns an error. You have four tests, so that part of your formula might be represented as =or(does not contain 1, does not contain 2, does not contain 3, does not contain 4)
.
Whichever of 1, 2, 3 and 4 (or indeed nothing or 0 or k etc) is contained, three at least of the four tests will PASS (if say it contains 4 then indeed it will not contain 3, etc). When the OR part is included in the rest of your formula it really contributes nothing, just the possibility of an error. Ignoring the error possibility, the overall result then is effectively the same as:
=if(A3="X","Yes","No")
Adjusting to A2 from A3 (so the formula may be entered in B2 where seems first required, then copied down) it may be seen that the OP’s formula merely returns Yes
if there is an X
in the cell immediately to its left, and in all other cases No
.
What seems to be required is “contains” for the tests, rather than “does not contain”, so some small adjustments should be sufficient:
=If(and(A2 = "X",OR(C2="Ready for QA Testing on Stage",C2="Deployed to Production",C2="Ready for Deployment",C2="Ready for QA Testing on Trunk")),"Yes","No")
I believe the issue is caused by filtered view sorting the column that contains input to a function. It can be reproduced in the following minimal example:
+---+-------+---+
| | A | B |
+---+-------+---+
| 1 | input | 1 |
| 2 | 5 | |
| 3 | 4 | |
+---+-------+---+
where B1 is the formula =A2-A3
. Create a filtered view for cells A1:B3 and use it to sort column A in ascending order. The result: B1 will display #REF error
The formula in cell A2 is referencing a range in the active filter that is not in the same row.
I can't really explain why this fails: my guess is that the logic of filtered view does not handle remapping cell references within the view.
But I can suggest an alternative approach: use FILTER
and SORT
, possibly putting results on different sheets for ease of sharing or reading. For example,
=SORT(FILTER(A2:A15, B2:B15=5), 1, TRUE)
keeps only the entries from A with 5 in column B, and presents them in ascending order. This formula could appear in another column (C,...), or on a different sheet.
Best Answer
Trying to do this with built-in spreadsheet functions is sure to be frustrating. But the problem is easily solved with a custom function that returns an array:
The first argument is the list of preferences, the second is the list of class sizes. The output is a rectangular array with
1
marking enrollment. The function does not give you the actual enrollment in classes, which you can easily find withSUM
.Here is the function I wrote: it should be pasted into Script Editor, Tools > Script Editor...
Output for your example agrees with yours: