Different result for two identical arguments [closed] - excel

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I used two IF functions to find the maximum value of a range, but return 0 if I slightly change the function by using AND function. Please help.
This works and returns an integer:
{=MAX(IF(MONTH(A58:A67)=MONTH(K50),IF(YEAR(A58:A67)=YEAR(K50),B58:B67)))}
this one always returns 0:
{=MAX(IF(AND(MONTH(A58:A67)=MONTH(K50),YEAR(A58:A67)=YEAR(K50)),B58:B67))}

Mostly one cannot using AND in array context properly.
In your example the
IF(MONTH(A58:A67)=MONTH(K50),IF(YEAR(A58:A67)=YEAR(K50),B58:B67))
evaluates to
IF({TRUE;FALSE;TRUE;FALSE;...;FALSE}, IF({FALSE;TRUE;TRUE;FALSE;...;TRUE}, {B58:B67}))
dependent on whether MONTH(A58:A67)=MONTH(K50) is TRUE or FALSE and YEAR(A58:A67)=YEAR(K50) is TRUE or FALSE.
That means if the first is TRUE then check the second and if the second also is TRUE, then take the corresponding value from array {B58:B67} into the MAX, else take FALSE, which counts 0, into the MAX.
But
IF(AND(MONTH(A58:A67)=MONTH(K50),YEAR(A58:A67)=YEAR(K50)),B58:B67)
evaluates to
IF(AND({TRUE;FALSE;TRUE;FALSE;...;FALSE},{FALSE;TRUE;TRUE;FALSE;...;TRUE}),{B58:B67})
So both the {TRUE;FALSE;...} arrays are in the AND and that will only be TRUE if there is not a single FALSE in both the arrays, else FALSE which counts 0 in the MAX.
And even if there would not be a single FALSE in both the arrays, then always the whole array B58:B67 would be the result in the MAX.

Related

How to ignore unnecessary input of Zeros (0) and dot (.) in a calculator app using kotlin/android studio [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 days ago.
Improve this question
1--> Ive been trying to make a calculator app. My problem is that I want my app to ignore unnecessary repeating input by the user to avoid having this kind of repeating zeros(0) and dot(.) : 00000.003, 3..03, 3+00000.003, etc
I'm new here so I don't know what else I could experiment on.
I've tried a combination of while loop with nested ifs with some conditions like text.startsWith, .endsWith("str", ignorecase: false) something like that for my onclick buttons.
Some code suggestions is highly appreciated.
2-->Also i've been thinking if there's a series of command/code where an individual textview will be created every time characters(created by onclick buttons) formed an integer/expression/decimalnumber(etc) as well as operation(+,-,*,/)
in a way that every number and math operations are separated into textviews(for editing purposes)
I hope someone can give me an idea and codes/commands that I might try to experiment with to develop my app
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
or
In this sample code, the text in the EditText is first converted to an Int value. If the conversion fails (that is, there is no numeric value in the text box), 0 is set by default. Next, the EditText's text is replaced with the numeric value with the redundant 0's removed.
val editText: EditText = findViewById(R.id.editText)
val number: Int = editText.text.toString().toIntOrNull() ?: 0
editText.setText(number.toString())
allows only text values ​​to be entered
val editText: EditText = findViewById(R.id.editText)
editText.filters = arrayOf(InputFilter { source, _, _, _, _, _ ->
if (source.toString().matches(Regex("[0-9]+"))) {
source
} else {
""
}
})

How to search a string for another string using HTBasic [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am trying to create a program which will search a string for another string, and return the string directly after that string.
Use the POS function to find the substring. Give it the string to search and the string you're looking for and it will return the position it's found at:
POS( S$, T$ )
S$ is the string you're searching
T$ is the string you're looking for
Return value is the position it's found at, or 0 if not found.
The strings are treated as arrays of characters.
A$="hello"
B$=A$[3,4] ! B$ will become "ll"
C$=A$[2] ! C$ will become "ello"
To get everything following the found substring you can use something like this:
1000 DIM A$[72]
1020 A$="Hello World, & goodbye." ! String to search
1040 T$="World, " ! String to look for
1060 L=LEN(T$)
1080 PRINT A$[L+POS(A$,T$)]
1100 END
Running this should give this result:
& goodbye.

How to convert a formated string into a one element tuple? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
It is possible to convert a single formatted string into a tuple, for example I am trying to transform a return from a function into a tuple.
E.g:
def GCcontent(self):
"Return GC content of the sequence given"
A = self.get_secuencia().count('A')
T = self.get_secuencia().count('T')
C = self.get_secuencia().count('C')
G = self.get_secuencia().count('G')
content = '{0:.2f}%'.format((G+C)*100/(A+T+G+C))
return content
The output is:
'XX.XX%'
But what I want to get is the following output:
('XX.XX%')
Is this even possible?. I tried tuple() function but it doesn't work as expected, is there another method to achieve this?
tuple([content]) will yield a 1-element tuple whose element is the string in content, but note that when printed, it appears as
('XX.XX%',)

mongodb get first element after find query [duplicate]

This question already has answers here:
How to get the last N records in mongodb?
(16 answers)
Closed 7 years ago.
I can't find the answer. I have a query that can return many answer and I want to get the last one. How to do it?
db.users.find({username: "bob", sort: {createdAt: -1}}).first()
I would like something like this.
do this to get last N records :
function last(N) {
return db.collection.find().skip(db.collection.count() - N);
}

How to count occurrences character in the string [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i have a string like "Nitin" write a method or logic to get output like this
N=2 I=2 T=1
means char count in string.
Try this:
string input= "asdjhrituerjkfdgf";
var resultList= input.GroupBy(e => e).Select(g => new { g.Key, Count = g.Count() }).ToList() ;

Resources