In my Excel worksheet E7 = 159.99 and H7 = 0.00%
I am trying to use an IF statement to get the correct result which should be 5%. However, if I use it in a nested IF statement like this:
=IF(H7>=8%,20%,IF(H7>=6%,15%,IF(H7>=3%,10%,IF(H7>0%,5%,IF(AND(H7=0%,E7>0,),5%,0)))))
The result is 0%.
When I break it down to just this part: =IF(AND(H7=0,E7>0,5%) I get the desired result of 5%.
What is wrong with the way I originally did it for it to be producing 0% instead of 5%
In this section of your original formula, you have an extra comma in the AND function:
=IF(AND(H7=0%,E7>0,),5%,0)
The extra column is causing a third input value of nothing, which evaluates to FALSE, causing the whole AND function to return false. I.e., right now, your function is the same as:
IF(AND(H7=0%,E7>0,FALSE),5%,0)
In your broken down part, you've included 5% after the extra comma as the third argument. Any non-zero amount is treated as TRUE. So that version works because it's the same as:
IF(AND(H7=0%,E7>0,TRUE),5%,0)
You just need to remove the extra comma and third argument:
IF(AND(H7=0%,E7>0),5%,0)
So the full formula is:
=IF(H7>=8%,20%,IF(H7>=6%,15%,IF(H7>=3%,10%,IF(H7>0%,5%,IF(AND(H7=0%,E7>0),5%,0)))))
Related
In the formula below, a #Value! error is returned.
=FILTER(FIND(";"&AS4756:AS4762&{6,7},AG4756),ISNUMBER(FIND(";"&AS4756:AS4762&{6,7},AG4756)))
Where ag4756 is 8034000;Y8033343543543;Y;38918;BS7 9XL;9;Male;N;N;N
and AS4756:AS4762 is
BS
NP
SN
GL
BA
CF
TA
When I chose evaluate formula, it returns the number 31 for the string BS7, and errors for all others. I'm trying to filter out the errors from the result, so I only get the result which is not an error. It also correctly returns TRUE for BS7, and false for all the others. But then the next step results in the error. Can anyone help?
edit: I want to return the position of the substring that starts with BS7. Or BS6, or NP6, or NP7, and so on.
Alright, I hope the following helps you out a bit; let's assume data (vertical) {BS;NP;SN;GL;BA;CF;TA} to be in A1:A7 and the lookup-string to be in B1. You are then concatenating a 2nd (horizontal) array {6,7} which would make up the following matrix:
Now to find these values in B1 using FIND(";"&A1:A7&{6,7},C1) would result in:
The next step for you would be to gather the numeric value. However, for the 2nd parameter, you have provided a 7*2 matrix and not a 1D-vertical or horizontal array of values. Therefor FILTER() will error out on exactly that step, returning the '#VALUE!'! And even so, if you would try to use MMULT() tricks to retrieve this array correctly you'd still need to deal with the fact you are trying to filter a matrix from the 1st parameter that is filled with errors. Therefor, I've shown how you could get the position from a relative easy formula that would deal with errors too:
=MAX(IFERROR(FIND(";"&A1:A7&{6,7},B1),""))
And to get the correct substring, use:
=MID(B1,MAX(IFERROR(FIND(";"&A1:A7&{6,7},B1)+1,"")),3)
Now that leaves us with the probability you have more potential substrings you'd like to be returned. If that is the case, let me know in the comments.
I've got the following formula that works correctly
=SUM(COUNTIFS(MachineData!N:N,{"*Arlington*","*RenewNorfolk*"}, MachineData!$X:$X,"Y"))
but now if I try to do the same but with "not arlington or not renewnorforlk" I get the wrong answer (it counts double the amount of values that I want to count)
=SUM(COUNTIFS(MachineData!N:N,{"<>*Arlington*","<>*RenewNorfolk*"}, MachineData!$X:$X,"Y"))
what is happening here?
Your first statement is equivalent to
=COUNTIFS(MachineData!N:N,"*Arlington*", MachineData!$X:$X,"Y") + COUNTIFS(MachineData!N:N,"*RenewNorfolk*", MachineData!$X:$X,"Y")
where the array constant is manually split into it two constituent parts.
If you try this with the second statement
=COUNTIFS(MachineData!N:N,"<>*Arlington*", MachineData!$X:$X,"Y") + COUNTIFS(MachineData!N:N,"<>*RenewNorfolk*", MachineData!$X:$X,"Y")
we can see that anything that isn't either Arlington or RenewNorfolk gets counted by both COUNTIFS statements, which isn't what we want the result to be.
The simplest solution is to use
=COUNTIFS(MachineData!N:N,"<>*Arlington*", MachineData!N:N,"<>*RenewNorfolk*", MachineData!$X:$X,"Y")
which requires all the criteria to be met for a data item to be counted.
I have a continuous set of numbers in cell I32 (123456789) of my worksheet. I want to use the new LAMBDA function to add each number with nine iterations (using recursion). The final value in cell L32 should be 45.
What I've got at the moment produces a #VALUE! error. I am basing it off the =REPLACECHARS example shown at the Microsoft Excel blog, where invalid characters are stripped out of a cell.
Formula:
=LAMBDA(Number,NumberGroup,
AddNumbers(
SUM(LEFT(Number,1)),
RIGHT(NumberGroup,LEN(NumberGroup)-1)
)
)(L32)
You are not using any recursion currently. You just trying to sum. If you really want recursion inside your LAMBDA() try something like:
=LAMBDA(Input,AddAll,X,IF(X=LEN(Input)+1,AddAll,Addnumbers(Input,AddAll+MID(Input,X,1),X+1)))
I created three parameters for LAMBDA():
Input - A reference to your cell/string of numbers;
AddAll - A grand total of the added numbers;
X - A simple counter, as if we were writing a function in VBA;
If you add the function to your name manager you can now call this using: =Addnumbers(I32,0,1), meaning:
Call our LAMBDA() function which we named "AddNumbers";
The 1st parameter must be the reference to our cell/string;
The 2nd parameter is our current total, zero at the start;
The 3rd parameter is the start of our counter, which should be 1.
I specifically added the nested IF() to get iteration going, i.o.w. recursion. The IF() checks the current state of the counter. Only if that is bigger than the total length of our input it will return the current total, otherwise; the recursion starts with calling the LAMBDA() all over again in the 2nd parameter (the FALSE parameter) where we use:
The same Input value;
Use MID() to add one of the numbers from the current index to our total of AddAll;
Increase our counter X by 1.
Now we have recursion out of the way, I'd say you have better options here if you want to use LAMBDA() since recursion is not needed. Try:
=LAMBDA(Input,SUM(--MID(Input,SEQUENCE(LEN(Input)),1)))
Call through =Addnumbers(I32).
All of the methods that I've used have 2 answer values (True or False).
How can I get the following with a formula?
If A1=1 then it's 11, if A1=2 the answer is 22, if A1=3 then it's 33, if A1=4 it's 44.
If the value your are evaluating is in cell A1, then the nested function would be as follows:
IF(A1=1,11,IF(A1=2,22,IF(A1=3,33,IF(A1=4,44,""))))
I put the 2 double commas at the end so the formula returns a blank instead of false.
I don't know if that's what you are asking about, but you can make multiple (nested) IF statements in one. For example:
IF(1=2;TRUE;IF(2=2;TRUE;FALSE))
You just put another IF in the FALSE part of IF statement. If that's not it, can you give a piece of the statement you tried and precise more what do you want?
=IF(AND(INT(A1)=A1,A1<=4,A1>=1),A1*11,"")
Now the above works for the condition you placed in your example, however if one were to go by your title alone you have a couple of options you could go with.
You first Option would be nested IF statements. Like you said each IF function has TRUE or FALSE. The trick is to put another IF function in for the TRUE result and another in for the FALSE results
IF(CHECK1, IF(CHECK2, TRUE2, FALSE2),IF(CHECK3, TRUE3, FALSE3))
The above give 4 potential results based on only 3 checks. Another option would be to do a check and supply a value for a TRUE result and another IF for a false result. Keep repeating the process. Conversely you could go the same route flipping TRUE FALSE option. It might look something like this:
IF(CHECK1, TRUE1, IF(CHECK2, TRUE2, IF(CHECK3, TRUE3, FALSE3)))
FALSE3 would be the result of all previous checks failing.
So for your case, your nested IF could look like (assuming the only valid entries are 1, 2, 3 and 4):
IF(A1=1,11,IF(A1,2,22,IF(A1=3,33,44)))
OR
IF(ISODD(A1),IF(A1=1,11,33),IF(A1=2,22,44))
and there are other options to work through the logic. there are also other checks you could be doing and results being displayed if your entries in A1 were not limited to the integers 1,2,3 and 4.
Now because you example is using the sequential integers 1,2,3 and 4 you could also use the CHOOSE function. Alternatively if you can make your criteria evaluate to sequential integers stating at 1 the CHOOSE function would work as well. Supply choose with an integer as the first argument and it will return the corresponding argument in the list that follows
CHOOSE(ARGUMENT,RESULT1, RESULT2,...,RESULTn-1, RESULTn)
In your case it would look something like:
CHOOSE(A1,11,22,33,44)
If you can not get sequential numbers for whatever reason and the gap is numbers is small and you are in the low integer count, you could leave a gap in results by providing "", or 0). lets say you has 1,3 and 4 as potential arguments, then your choose might look like:
CHOOSE(A1,11,"",33,44)
=IF(A1<>"",INDEX({11;22;33;44},A1),"")
=IF(AND(ISNUMBER(A1),A1<=4),A1*11,"")
I am trying to calculate the percentage, here the rules are as follows:
01. Employees working in IT department for more than 10 years will get 7% and rest of the IT guys will get 6.5%
02. And for rest of the departments, we have different percentages
Here H column represents various departments and F is working experience and in column I we're getting the main value from which we have to calculate the percentages.
Here's what I tried
=IF(AND(H5="IT",F5<10),I5*6.5%,I5*7%,IF(H5="PRODUCTION",I5*9%,IF(H5="MARKETING",I5*6%,IF(H5="LAW",I5*6%,IF(H5="HR",I5*9.36%)))))
This is showing You've entered too many arguments
Your first If statement, really had one too many argument.
=IF(AND(H5="IT",F5<10),I5*6.5%,IF(H5="PRODUCTION",I5*9%,IF(H5="MARKETING",I5*6%,IF(H5="LAW",I5*6%,IF(H5="HR",I5*9.36%,I5*7%)))))
Since each new if is nested as the FALSE eventuality. Look at the end for that 7%.
Edit:
My bad(reading your comment made me realize), there are two error in your formula.
One has been discussed, the second is how you nested those IT percentage.
=IF(AND(H5="IT",F5>=10),I5*7%,IF(AND(H5="IT",F5<10),I5*6.5%,IF(H5="PRODUCTION",I5*9%,IF(H5="MARKETING",I5*6%,IF(H5="LAW",I5*6%,IF(H5="HR",I5*9.36%,""))))))
In this version I added another IF statement. We could have avoided it by defining either one of the IT's rate as the ELSE result same as my initial answer. Now all predictable eventuality have their own TRUE match. An unexpected value will return an empty string. Maybe you want it to be 0 instead...
(1) IF(AND(...))= conditions
(2) I5 * 6.5% = value if true
(3) I5 * 7% = value if false
Therefore, you already indicate value if false and another if statement is not allowed. I would remove (3) and put it to the very end of your formula. As such, once none of the previous conditions are met, it will automatically take on the value of 7%.