I am trying to build an IF formula but I am getting an error that I have too many arguments. Any idea how to fix this?
=IF(BZ190=$C$163,$C$163, IF(BZ190=$C$163*$C$165,$C$163*$C$166, IF(BZ190=$C$163*$C$166,$C$163*$C$167, IF(BZ190=$C$163*$C$167,Z190=$C$163*$C$168, IF(BZ190=$C$163*$C$168,$C$163*$C$169, IF(BZ190=$C$163*$C$169,$C$163*$C$170, IF(BZ190=$C$163*$C$170,$C$163*$C$171, IF(BZ190=$C$163*$C$171,$C$163*$C$172, IF(BZ190=$C$163*$C$172,$C$163*$C$173, IF(BZ190=$C$163*$C$173,$C$163*$C$174, IF(BZ190=$C$163*$C$174,$C$163*$C$175, IF(BZ190=$C$163*$C$175,$C$163), IF(AND((SUM(BZ190:BZ$190)-CA$168)<0,BZ190=""),$C$163*$C$165,"")))))))))))
The last but one if-clause looks like this:
IF(BZ190=$C$163*$C$175,$C$163),
^
|
| bracket is obsolete
There should not be a bracket at the end, it should just be:
IF(BZ190=$C$163*$C$175,$C$163,
But I have another point here: imagine that, within half a year or within a year, you need to modify something. How will you find out what all those things mean? Therefore I'd advise you to use names, something like:
$C$163 equals "interest_rate"
$C$165 equals "student_income"
...
Like this, your formula will become something like:
IF(BZ190=interest_rate,interest_rate,
IF(BZ190=interest_rate * student_income, ...
This will be much clearer to read and to maintain. And, oh, before I forget: writing the formula in multiline (one if-clause per line) also increases readability and maintainability.
Related
I'm trying to replace some messy data with regex in a data frame, the column has qualification values, but they are messy. For example, I have 'plastic','plastique','Plasticpackage',or 'Karton','carton','Carton'... in the column 'packaging', but they all mean the same thing, that is 'plastic' or 'Carton', things like that. Therefore Im trying to replace all these values with .replace and Regex. My code looks like this:
dict1={r'[cK]arton':'Carton',r'\W*((?i)plasti(?-i))\W*':'Plastique',r'[cC]onserve':'Conserve'}
df['packaging'].replace(dict1,inplace=True,regex=True)
However, when i execute it gives me the error:missing : at position 18
I have checked, line 1 to line 18 have 17 missing values not only at line 18, so why i have this error? Should I tell python to ignore na values? But the replace() function does not seem to have the ignore na option.
Thank you very much in advance
You cannot use inline modifiers in Python re at a non-initial position in a regex. Besides, it does not support (?-i) notation (to disable the effect of the preceding (?i)).
Instead, you can use an inline modifier group, (?i:...).
So, you need to fix the regex definitions likes this:
dict1={
r'[cK]arton':'Carton',
r'\W*(?i:plasti)\W*':'Plastique',
r'[cC]onserve':'Conserve'
}
Or, r'\W*(?i:plasti)\W*' can also be written as r'(?i)\W*plasti\W*'.
This might be a simple fix I'm unsure. I have the following formula which I would like to be able to drag up and down =IF(C311>B311,IF(C310>B310,IF(B309>C309,IF(C312>B312,2,1),0),0),0)
I'm guessing AND can be implemented in some way but I'm not sure. The logic behind my goal is if C311>B311 AND C310>B310 AND B309>C309 then check to see if C312>B312 if it is then put a 2 else put a 1. Perhaps there is another solution as well I'm not thinking of.
Try this: =IF(AND(C311>B311,C310>B310,B309>C309),IF(C312>B312,2,1),"")
Last argument I left it as "" but replace it to whatever you need.
Just another approach-
=IF((C311>B311)*(C310>B310)*(B309>C309),IF(C312>B312,2,1),"")
I have a set of data that is generated:
=((E31/320)^2)/(2+(E31/380))
=((E32/320)^2)/(2+(E32/380))
=((E33/320)^2)/(2+(E33/380))
...
I want to create a sum of these, but I don't want to just SUM them together; I want to write a function that put these together. I came up with this row:
=SUMPRODUCT(((ROW(E1:INDEX(E31:E63;C34)))/320)^2/(2 + (E31:E63/380)))
The problem with this line is it seems to overdo the whole thing. I need to somehow use one variable for the both E31:E63 intervals, because it will otherwise loop through the second E31:E63 n-times, instead of using the same value.
As I see it, there are two solutions.
Write the data in columns, but using the first solution
Write the function, but try to find something that makes the two E31:E63 work as one variable.
I want to implement the second option.
I believe
=SUMPRODUCT(((E31:E63/320)^2)/(2+(E31:E63/380)))
Will do what you want.
I have step where I am have String Array, something like this:
Then Drop-dow patient_breed contains ['Breed1', 'Breed2',.... Breed20']
I need to split this text on two lines. I know that in Gherkin there is expression """. I try something like this:
Then Drop-dow patient_breed contains ['Breed1',
"""
'Breed2',.... Breed20']
"""
It didn't help. Is there any solution?
What do you gain by putting this string in your scenario. IMO all you are doing is making the scenario harder to read!
What do you lose by putting this string in your scenario?
Well first of all you now have to have at least two things the determine the exact contents of the string, the thing in the application that creates it and the hardcoded string in your scenario. So you are repeating yourself.
In addition you've increased the cost of change. Lets say we want our strings to change from 'Breedx' to 'Breed: x'. Now you have to change every scenario that looks at the drop down. This will take much much longer than changing the code.
So what can you do instead?
Change your scenario step so that it becomes Then I should see the patient breeds and delegate the HOW of the presentation of the breeds and even the sort of control that the breeds are presented in to something that is outside of Cucumber e.g. a helper method called by a step definition, or perhaps even something in your codebase.
Try with a datatable approach. You will have to add a DataTable argument in the stepdefinition.
Then Drop-dow patient_breed contains
'Breed1'
'Breed2'
...
...
...
'Breed20']
For a multiline approach try the below. In this you will have to add a String argument to the stepdefinition.
Then Drop-dow patient_breed contains
"""
['Breed1','Breed2',.... Breed20']
"""
I would read the entire string and then split it using Java after it has been passed into the step. In order to keep my step as a one or two liner, I would use a helper method that I implemented myself.
Highly likely this is a syntax error, but it's not throwing any errors.
=IF(ISERROR(MATCH(MID(Z2,28,6),$AF$1:$AG1,0)),"Mismatch","Included")
I have Z2, Z2 contains the following text:
"Revenue account for invoice P13930."
Or something like that, so the Mid function is suppoused to match that code, P13930, and not if it is within the specified cells (Here, AF1 and AG1)
I tried copying the whole text, or even just the code to AF1 and AG1, but it never writes a match. What's wrong with it?
Based it on my prototype:
=IF(ISERROR(MATCH($AE1,$AF1:$AG$1,0)),"Mismatch","Included")
Which does happen to work.
EDIT: I forgot to mention, I was wondering how to include the following scenarios:
Sometimes the code would look like this: P13930. and other times like this: P13930A. I'm not sure how to consider these as my knowledge is limited to Mid , Left , and Right. And as Jordan Mentioned, MATCH would be out of the picture given these variations.
If AF1 and AG1 contain codes like P13930A, you can use a wild card to match them like this
=IF(ISERROR(MATCH(MID(Z2,29,6)&"*",$AF$1:$AG1,0)),"Mismatch","Included")
Could you please specify your question:
First which we can advice, is to correct mid function argument:
=IF(ISERROR(MATCH(MID(Z2,29,6),$AF$1:$AG1,0)),"Mismatch","Included")
MID(Z2,29,6) - will give you result P13930
and then you want to find this code in some area, don't you? for example in the area AF1:AG1.
Please specify the result which you want to see in the cell AF2:
(a) code P13930; (b) INCLUDED - if area AF1:AG1 includes code P13930; (c) MISMATCHED - if area AF1:AG1 does NOT include code P13930 and etc.