This is probably a simple fix (although me thinking this, means it probably isn't), so I apologise in advance if this is mere child's play.
In an excel sheet I am working on, I have a range (for the sake of this example is A1:A10) which can contain one of 3 variables (not including blanks) - A, B or C.
I require a formula in another cell to review the range in question and output a value based on the following rules in this priority:
If A appears anywhere in the column, regardless of other inputs, display A;
If B and C appear in the column, display A;
If only B appears in the column, display B;
If only C appears in the column, display C; and
If all cells within the column are blank, display blank
For rules 1-4, any blank cells within the column should not be considered. It is only where all cells are blank, i.e. rule 5, that this should be considered.
I have tried IF formulas but have found these only consider a single cell.
Also I have attempted using SUMPRODUCT along with IF but have hit a snag. The formula I used was:
IF(SUMPRODUCT(--(--(A1:A10="A")),"A",IF(SUMPRODUCT(--(A1:A10="B")),IF(SUMPRODUCT(--(A1:A10="C")),"A",IF(SUMPRODUCT(--(A1:A10="B")),"B",IF(SUMPRODUCT(--(A1:A10="C")),"C","")))))
Now I know this appears longwinded but until rule 3 it works fine. When trying for rule 4 or 5 the formula only returns FALSE
I'm all for the above formula being tweeked so that it works or for another formula entirely but I've tried searching everywhere and can't find anything on this (although this is probably down to me not phrasing my question/searches correctly).
Any help would be much appreciated. Thanks in advance!
Using your provided example, this will yield desired results:
=INDEX({"","C","B","A"},MATCH(SUMPRODUCT({3,2,1},--(COUNTIF(A1:A10,{"A","B","C"})>0)),{0,1,2,3}))
Not the easiest answer, but it works as well:
{=IF(SUM(--($A$1:$A$10="A")+(($A$1:$A$10<>"A")*(SUM(--($A$1:$A$10="B"))>0)*(SUM(--(A1:A10="C"))>0)))>0,"A",IF(SUM(--($A$1:$A$10="B"))>0,"B",IF(SUM(--($A$1:$A$10="C"))>0,"C",IF(SUM(--(ISBLANK($A$1:$A$10)))=ROWS($A$1:$A$10),""))))}
Admittedly not nearly as elegant as the above solution.
Related
I am trying to create a formula that checks for several things at the same time but I am having trouble with one part of it.
The formula is the following:
=IF(COUNTIFS($N$2:$N$17095,N3,$K$2:$K$17095,"<>"&"")>6,
IF((SUMPRODUCT(--(ROUND($K$2:$K$49,2)=ROUND(K3,2)))>9),"Always Late / Possible Automation",
IF(COUNTIFS($N$2:$N$17088,N3,$K$2:$K$17088,"<3.5")>0,"Delivered Earlier At Least Once",IF(COUNTIFS($N$2:$N$17088,N3,$K$2:$K$17088,">3.5")>6,"Always Late","False"))))
The first part checks how many entries in the range having the same value as it is in cell N3 have values different to blank and we want those to be more than 6.
Second part is the tough one, it is supposed to check how many values in the rounded range match the rounded value in cell K3. The issue is the formula checks the whole range and I want to check only for the values which match N3 (in essence like the CountIf works only for that value).
The rest is not so relevant.
Some example data:
![enter image description here][1]
As you see in the end of the table the formula with the rounding works but only because I have limited the data shown to 3 unique values in column N. Even here though if i have a blank it doesnt work becaus ei haven't considered it.
Thanks in advance.
Assuming you have Office 365 compatibility/Excel version, use a bunch of filters. To avoid an unwieldy formula I've extended ranges to maximum number of rows (customize as required)...
=LET(x_,$E$3:$E$25,a_,FILTER($E$3:$E$25,--(x_=E3)),b_,FILTER($B$3:$B$25,--(x_=E3)),IF(SUM(--(a_=E3)*(b_<>""))>6,IF((SUMPRODUCT(--(ROUND(b_,2)=ROUND(B3,2)))>9),"Always Late / Possible Automation",IF(SUM(--(a_=E3)*(b_<3.5))>0,"Delivered Earlier At Least Once",IF(SUM(--(a_=E3)*(b_>3.5))>6,"Always Late","False")))))
Note: filter does not appear to work too well within countifs for some reason (must be related to syntax RE: arrays vs. criteria TBC). Thus have replaced countifs(filter_range,X) eqn 'types' with sum(--(filter_range=X)) which works as intended.
I have done quite a bit of searching on this, and have found a way to set up nearly every kind of formatting rule except for this specific case. I need an entire row of the table to be highlighted only when two different conditions are present. The two conditions are:
1 cell in column E does not contain “text 1”
2 cell in column H does contain “text 2”
I need the whole table (upwards of a few thousand rows, by 12-ish columns) to be considered, and I can’t modify any of the data in the tables, or the sheets themselves.
After some playing around with solutions to similar but different problems, I ended up with a formula that seems like it should work... the logic seems right, and I’m pretty sure the syntax is correct also, but when I add the formula to the conditional formatting rule, nothing happens. It accepts the formula, but it just does nothing.
I tested it out by applying the formula to a simple test sheet and put it in column C, and it results in “TRUE” being in column C when the conditions are present, and “FALSE” being in column C when one or both of them are not present, which seems like it’s behaving correctly. Any tips would be appreciated!
Here’s what I have currently:
=AND(IF(IFERROR(SEARCH(“text 1”, $E1), 0),FALSE,TRUE),IF(IFERROR(SEARCH(“text 2”, $H1),0),TRUE,FALSE))
(Edit: there are asterisks before and after the “text 1” and “text 2”, inside the quotes.)
When using a formula in CF you must produce a formula which evaluates to either TRUE or FALSE, as in
=AND(ISERROR(SEARCH("text 1", $E1)),ISNUMBER(SEARCH("text 2", $H1)))
I have a worksheet looking at football results. I have inserted a formula to discover the longest sequence of blank cells which indicates to me how many games between either wins/draws/defeats. Taking wins as an example which I have in Column H, this formula (The cells in Column H contain either a 1 or are blank)
{=MAX(FREQUENCY(IF(H1:H5077="", ROW(H1:H5077)), IF(H1:H5077=1, ROW(H1:H5077))))}
has told me that the longest sequence without a win for the selected team was 19 matches. That formula and result on my workbook is in cell H5094
What I want to do is discover where amongst 5000+ matches that sequence is?
I've tried this formula which I've used before in an adjacent column and copied down
=IF(COUNTIF(OFFSET(H2,0,0,$H$5094,1),1)=$H$5094,"here","")
however it hasn't worked. I think the mistake is within the formula, possibly the 0 and 1 but I don't know how to put it right, I've tried several variations.
Any help much appreciated.
The method looks fine to me, but the easiest way would be to use COUNTBLANK instead of COUNTIF, so the formula would be:-
=IF(COUNTBLANK(OFFSET(H2,0,0,$H$5094,1))=$H$5094,"here","")
or alternatively
=IF(COUNTIF(OFFSET(H2,0,0,$H$5094,1),"")=$H$5094,"here","")
I noticed that you could get some extra 'heres' if the longest sequence came at the end of the range, but you could fix it by putting a '1' in H5078.
I'm trying to see if 2 cells C2, exist in the column G and H in the same order.
If yes, it will bring back the relevant cell in the F column.
However, it is not working as expected.
I've got this error message #VALEUR!
This is the formula I've used
=INDEX(F2:F60000;EQUIV(C2:D2;G1:H60000;0))
Any suggestions are welcomed.
I don't think I need VBA but it may be the case, although I hope not.
You can do it via a simple IF Condition like
=IF(C2=G2,IF(D2=H2,F2,"False"))
I have 2 columns in a spreadsheet. One column has around 26 extra rows than the other. I've been trying various formulas to highlight or somehow indicate which columns are missing from the smaller of the lists...
I tried filling a 3rd colum with this :
=FIND(B1,A1:A1102)
which I though returned 1 if b1 was in the list a1:a1102 alas it doesn't seem to be true.
Anybody got any solutions for comparing 2 lists and isolating differences?
Thanks
To use MATCH, go with something like the following:
=IFERROR(MATCH(B1,$A$1:$A$1102,0),0)
entered into cell C1 and copied down to the end of the data in column B
This assumes that column B contains the longer list and A the shorter, of course.
The MATCH formula will return the row in which B1 is matched in A.
You can use a combination of if, iferror and vlookup functions.
=IF(IFERROR(VLOOKUP(B1,$A$1:$A$10,1,FALSE),"missing")="missing", 1, 0)
This will find matches in column A for the values in column B. If the value is missing, the iferror will report it missing (#N/A). Then the if function will output a 1 for the missing values and a 0 for those found.
EDITED:
My bad, I suggested the wrong function - except the absolute reference, you need to use MATCH - as suggested in other answers: =MATCH(B1,$A$1:$A$1102,0) or look up the whole column: =MATCH(B1,A:A,0).
Missing items will be returned as #N/A, but it easily handled with IFERROR.
I know this is a bit old, but I could not get MATCH() to work across different tabs in the same workbook. Also, I'd rather not add columns if I don't have to. What worked for me, was to use conditional formatting:
Select one column that you want to test (assume it's 'Z' for this example)
Select Conditional Formatting -> New Rule
Select 'Use a formula ...'
Use =COUNTIF('otherTab'!$A:$A, $Z1) - where 'otherTab' is the name of the other tab, 'A' is the column in that tab you want to test against and 'Z' is the column in THIS tab
Set the color scheme that something that says "I found a match!" to you
Click OK
Then you can do the same on the other column if you need to check both.
I think you need to use MATCH instead of FIND
Or if you want to be fancier about it, check out this thread:
https://superuser.com/questions/289650/how-to-compare-two-columns-and-find-differences-in-excel