Excel formula not working: date and number ranges - excel

I have been trying to make this work in cell I1:
=IF(B18="","",IF(AND(OR(C16=7,C16="J",C16=8),B18< 300,D16< DATE(2021,5,15),300,IF(B18< 350),350,B18),(IF(AND(OR(C16=4,C16="T"),B18< 500),500,B18))))
Where:
if C16 is 7 or J or 8
and
the date in D16< DATE(2021,5,15)
and
B18<300
Result in I1=300 otherwise B18 (in case B18 is over 300).
Otherwise if D16> DATE(2021,5,15) and B18<350 I1=350.
If B18>350, I1=B18
Sorry...it looks messy!
R

It seems like your formula and code don't align with each other.
But however, with the explanation you have provided, I could only write the following formula. Hope it works for you.
=IF( B18="" , "" , IF( AND( OR(C16=7,C16="J",C16=8), D16<DATE(2021,5,15) ) , IF(B18<300, 300, B18), IF( D16>DATE(2021,5,15) , IF(B18<350, 350, B18) ) ) )

I think I solved it like this:
=IF(B18="","",IF(AND(OR(C16=4,C16="T"),B18<500),500,IF(AND(OR(C16=7,C16="J",C16=8),B18<300,D16<DATE(2021,5,15)),300,IF(B18<350,350,B18))))

Related

One formula to combine 2 lists (2021)

I have one list starting from B1 (=UNIQUE(A1:A8)), and another list starting from D1 (=UNIQUE(C1:C8)). Thus =B1# and =D1# in other cells both spill.
Now, I would like to know if we could find one formula to combine List B1# and List D1# (extract only unique values) by dynamic array functions, LAMBDA, LET, etc.
I don't want to move the position of the two lists. Does anyone have any good idea?
I may not be following what you want the shape to be, but here are two shapes:
Side-by-Side
=CHOOSE({1,2},B1#,D1#)
If you want it to take the original A and C columns as input and do all the work, then:
=CHOOSE({1,2},UNIQUE(FILTER(A:A,NOT(ISBLANK(A:A)))),UNIQUE(FILTER(C:C,NOT(ISBLANK(C:C)))))
or a LET version of the same which does not require retyping the inputs:
=LET( Ltrs, A:A,
Nmbrs, C:C,
CHOOSE( {1,2},
UNIQUE(FILTER(Ltrs,NOT(ISBLANK(Ltrs)))),
UNIQUE(FILTER(Nmbrs,NOT(ISBLANK(Nmbrs)))) ) )
End-on-End
=LET( uLtrs, B1#,
uNmbrs, D1#,
ltrCt, ROWS(uLtrs),
idx, SEQUENCE( ltrCt + ROWS(uNmbrs) ),
IF( idx <= ltrCt, uLtrs, INDEX( uNmbrs, idx-ltrCt ) ) )
Similar as above, if you want it to take the original A and C columns as input and do all the work, then:
=LET( Ltrs, A:A,
Nmbrs, C:C,
uLtrs, UNIQUE(FILTER(Ltrs,NOT(ISBLANK(Ltrs)))),
uNmbrs, UNIQUE(FILTER(Nmbrs,NOT(ISBLANK(Nmbrs)))),
ltrCt, ROWS(uLtrs),
idx, SEQUENCE( ltrCt + ROWS(uNmbrs) ),
IF( idx <= ltrCt, uLtrs, INDEX( uNmbrs, idx-ltrCt ) ) )
Both spill the results.
Place the following code into cell F2 and drag formula downwards to F14. This will give you a unique list of both Column A and Column D
=IF(IFERROR(IF(INDEX($A$1:$A$99999,MATCH(0,COUNTIF($F$1:F1,$A$1:$A$99999),0))=0,NA(),INDEX($A$1:$A$99999,MATCH(0,COUNTIF($F$1:F1,$A$1:$A$99999),0))),INDEX($C$1:$C$99999,MATCH(0,COUNTIF($F$1:F1,$C$1:$C$99999),0)))=0,NA(),IFERROR(IF(INDEX($A$1:$A$99999,MATCH(0,COUNTIF($F$1:F1,$A$1:$A$99999),0))=0,NA(),INDEX($A$1:$A$99999,MATCH(0,COUNTIF($F$1:F1,$A$1:$A$99999),0))),INDEX($C$1:$C$99999,MATCH(0,COUNTIF($F$1:F1,$C$1:$C$99999),0))))
Let me know if you need it to behave differently.

How to use an IF function in Excel formula with conditions consisting of both negative and positive numbers

I have an excel sheet with values in both negative and positive sign. Based on the values, I want them to assign a category. The excel sheet looks like this
I have to apply the formula on the SPI values.
I am using an IF statement.
The formula I am using is:
=IF(C3>=2,"EW",IF(1.5<=C3<=1.99,"VW",IF(1<=C3<=1.49,"MW",IF(-0.99<=C3<=0.99,"NN",IF(-1.49<=C3<=-1,"MD",IF(-1.99<=C3<=-1.5,"SD","ED"))))))
The problem is that every time it shows only "ED". It is as if it is skipping all the conditions and running only the last case. How can I fix this?
Try this, but check the values:
IF(C3>=2,"EW",IF(C3>=1.5,"VW",IF(C3>=1,"MW",IF(C3>=-0.99,"NN",IF(C3>=-1.49,"MD",IF(C3>=-1.99,"SD","ED"))))))
You could also consider vlookup() like this:
Which will be easier to maintain...
You can understand better what is going on using a beautifier (for example this) so your formula:
=IF(
C3 >= 2,
"EW",
IF(
1.5 <= C3 <= 1.99,
"VW",
IF(
1 <= C3 <= 1.49,
"MW",
IF(
- 0.99 <= C3 <= 0.99,
"NN",
IF(
- 1.49 <= C3 <=- 1,
"MD",
IF(
- 1.99 <= C3 <=- 1.5,
"SD",
"ED"
)
)
)
)
)
)
From your example is not clear which columns and row are, could you provide also excel file ?
Unlike many programming languages, Excel can't handle defining two delimiter at once for a variable. This won't work:
=IF(C3>=2,"EW",IF(1.5<=C3<=1.99,"VW", ...)
Since excel does not recognize 1.5<=C3<=1.99, it considers the statement as FALSE and checks what to do in that case, which at the end of your IF statement is "ED".
In your case, you have to use AND():
=IF(C3>=2,"EW",IF(AND(C3>=1.5,C3<=1.99),"VW", ...)
I haven't tested Solar Mike's solution, but his answers are generally pretty good. (Though the part with IF(C3>=--1.49,... probably needs to be rewritten to IF(C3>=-1.49,...) :)

Can't find the right formula in Excel

I have 3 conditions based on this table: https://i.stack.imgur.com/GAeT0.png
Conditions are:
In column "Stadiu" (starting from D5) should type:
RIDICATA if the number from Populatie is > 1000 and the column Eveniment has Mondiala in it
MEDIE if the number from Populatie is > 500 or <= 1000 and the column Eveniment has Mondiala
MEDIE if the number from Populatie is > 500 and the column Eveniment has Internationala
SLABA = rest
I tried this formula:
=IF(AND(C5>1000;FIND("Mondiala";A5));"ridicata";IF(AND(C5>500;C5<=1000;FIND("Mondiala";A5));"medie";IF(AND(C5>500;FIND("Internationala";A5));"medie";IF(AND(C5<500);"slaba"))))
but it doesn't work.
I am new to Excel, so I hope you guys can help me what I am doing wrong. Thanks!
When evaluating the formula, anywhere that the FIND function doesn't find the string you're searching for, it returns a #VALUE error instead of 0 or FALSE. That's causing the whole formula to fail in those circumstances, so you need to handle those cases with IFERROR.
In addition, your nesting wasn't quite correct. You did not have an ELSE result for cases where all three tests failed. The following formula should return the expected results based on your criteria provided:
=IF(AND(C5>1000;IFERROR(FIND("Mondiala";A5);0));"Ridicata";IF(OR(AND(C5>500;C5<=1000;IFERROR(FIND("Mondiala";A5);0));AND(C5>500;IFERROR(FIND("Internationala";A5);0)));"Medie";"Slaba"))
Might be a little easier to relate it to your test criteria by spreading it out into sections:
=IF(
AND(
C5>1000;
IFERROR(FIND("Mondiala";A5);0)
);
"Ridicata";
IF(
OR(
AND(
C5>500;
C5<=1000;
IFERROR(FIND("Mondiala";A5);0)
);
AND(
C5>500;
IFERROR(FIND("Internationala";A5);0)
)
);
"Medie";
"Slaba"
)
)

Combine 2 excel formulas

in column C i have a text with "xxx has been deleted because... " or "xxx have been deleted because... " . I have 2 formulas:
=IF(C3<>"",IF(FIND("has been deleted",C3),LEFT(C3,FIND("has been deleted",C3)-1),"DDDD"),"AAAAAAA")
and
=IF(C5<>"",IF(FIND("have been deleted",C5),LEFT(C5,FIND("have been deleted",C5)-1),"DDDD"),"AAAAAAA")
I want to combine the two but it doesn't work. Here is what i have tried :
=IF(C4<>"",IF(FIND("have been deleted",C4),LEFT(C4,FIND("have been deleted",C4)-1),IF(FIND("has been deleted",C3),LEFT(C3,FIND("has been deleted",C3)-1),"DDDD")),"AAAAAAA")
=IF(C4<>"",IF(FIND("have been deleted",C4),LEFT(C4,FIND("have been deleted",C4)-1),LEFT(C3,FIND("has been deleted",C3)-1)),"AAAAAAA")
formula:
=IF(C1="", "AAAAAAA",
IF( AND( ISERROR( FIND("has been deleted",C1)),
ISERROR( FIND("have been deleted",C1))),
"DDDD",
LEFT(C1, IFERROR( FIND("has been deleted",C1),
FIND("have been deleted",C1)) -1))
)
and here is my test based on the sample you described:
please note formula needs pasting into D1 and dragged down. as in picture
=IF(C1="","AAAAAA",IF(OR(ISERROR(FIND("have been deleted",C1)),ISERROR(FIND("have been deleted",C1))),IF(ISNUMBER(FIND("has been deleted",C1)),LEFT(C1,FIND("has been deleted",C1)-1),IF(ISNUMBER(FIND("have been deleted",C1)),LEFT(C1,FIND("have been deleted",C1)-1),"DDDDD"))))
Please enter this formula into D1 and it will show result based on value C1.
I hope we understood your question properly.

IF(AND statement with multiple criterias

I am trying to write a formula to include multiple criteria and can't seem to get it right.
The formula works as is however I need to include "SHOT10","SHOT20", "SH15" and "SH20"
=IF(AND(C5194="SHOT15",H5194="",I5194=""),E5194,"")
Can someone assist me with modifying the above formula?
The AND(C5194="SHOT15",H5194="",I5194="") is equivalent to saying:
C5194="SHOT15" And H5194="" And 15194=""
So what you have in VBA code is:
If C5194="SHOT15" And H5194="" And 15194="" Then
ActiveCell = E5194
Else
ActiveCell = ""
End
You can use AND( and OR( to specify different parameters.
For example, If I want to pickup 3 different values in 'A1', but make sure that 'B1' and 'C1' are blank, I can use:
=IF(AND(OR(A1="A",A1="B",A1="C"),B1="",C1=""),"True","False")
So in your case specifically:
The issue now is that I now need to also consider SHOT10, SHOT20, SH15 and SH20 as well. Meaning that if either SHOT15, SHOT10, SHOT20, SH15 or SH20 appears in C5194 and H5194 is blank and I5194 is also blank then return the value of E5194 else return blank. The key is that all the conditions must be met for the value of E5194 be returned
Your formula becomes:
=IF(AND(OR(C5194="SHOT15",C5194="SHOT10",C5194="SHOT20",C5194="SH15",C5194="SH20"),H5194="",I5194=""),E5194,"")
Edit: Shorten Using an array constant per barry houdini:
=IF(AND(OR(C5194={"SHOT15","SHOT10","SHOT20","SH15","SH20"}),H5194="",I5194=""),E5194,"")
=IF(
AND(
OR( C5194="SHOT10", C5194="SHOT15", C5194="SHOT20", C5194="SH15", C5194="SH20" ),
H5194="",
I5194=""
),
E5194,
""
)

Resources