ROWS(INDEX()) or COLUMNS(INDEX()) bug in excel? - excel-formula

If I enter the following as an array formula in a cell (CTRL+SHIFT+ENTER instead of ENTER)
=ROWS(INDEX($A$1:$A$2,{1;2}))
the value returned is 1, whereas the expected value is 2.
Is this a bug in Microsoft excel? I checked that the value returned is 2 in openoffice calc.

The difference comes in the evaluation of {1;2}
Assuming other things are equal, it seems that Open Office evaluates this to be 0, while Excel evaluates this to be 1.
If you substitute those values instead of the {1;2} you will see the different results:
0 in excel return your expected value of 2
1 returns your observed value of 1

Related

How to find the difference in values for each entry in one of the columns

What formula could I use to find the Average difference for each time there is an entry for column B.
For example in the excerpt below the average would be 7. We would only use rows 2 and 3 because there is an entry in them. If I can I would like to avoid using VBA.
Submitted
Returned
10/2/2022
10/3/2022
10/9/2022
10/17/2022
10/25/2022
10/25/2022
10/9/2022 - 10/3/2022 = 6
10/17/2022 - 10/25/2022 = 8
(6 + 8) / 2 = 7
I tried finding a for each function in excel and I tried using =Average(B-A)
You have several options. Using AVERAGE, you can use the following in cell D1:
=AVERAGE(IF(B2:B5-A2:A5 < 0, "", B2:B5-A2:A5))
This function ignores empty values ("") as part of the average (but AVERAGEA doesn't). The resulting array of IF statement will be the difference in days of the Returned value and the Submitted value if the Returned is not empty, otherwise, it will be an empty string. Empty dates are represented in Excel as 0 and any other non-empty date is a positive number, so B2:B5-A2:A5 < 0 meets our requirement.
Another alternative is to use SUMPRODUCT (in cell D2):
=SUMPRODUCT(B2:B5-A2:A5,--(B2:B5>0))/COUNT(B2:B5)
Note: You cannot use AVERAGEIF or AVERAGEIFS with the input argument: B2:B5-A2:A5 because it is not a range and the first input argument is required to be a range.
Here is the output:

Need to add the cells if it is blank means blank if the sum is morethan 2 type as 1 and if sum is equal to 2 type as 0.5 else 0

I need to add up the cells. If it is blank - means blank, if the sum is more than 2 - type as 1, and if sum is equal to 2 - type as 0.5, otherwise 0.
Even if it's blank, I'm getting 0.
=IF(ISBLANK('period wise'!CF5),"",IF(SUM('period wise'!CF5:CI5)>2,"1",IF(SUM('period wise'!CF5:CI5)=2,"0.5","0")))
It works fine testing it. I think the cell referred to is showing no data, but contains a formula. To Excel that means it's not blank. You can refer to it as if =IF(LEN('period wise'!CF5)=0,"",IF(SUM('period wise'!CF5:CI5)>2,1,IF(SUM('period wise'!CF5:CI5)=2,0.5,0)))
PS I also removed the "'s around the results, not sure why you would want the numbers to output as text.

Excel: Count if value is present in 3 columns

How do I count the number of values that are present across ALL THREE columns?
For example, “L160” is the only value that is in all 3 columns, so the formula should equal 1.
Screenshot of values
The following formula will check if the value in C is present at least once in A, at least once in B, and makes sure that the value in C is not blank. If all three conditions are true it will return 1 and it fails it will return 0
=--AND(COUNTIF(A:A,C2)>=1,COUNTIF(B:B,C2)>=1,C2<>"")
Place the above formula in am empty cell and copy down as need be.
You can start, using the Match() function: if the string is found, the location is shown. If not, you get an error message. This return value is checked, using an If() function: if the value is ok (larger than 0), the value 1 is returned, otherwise 0.
=IF(MATCH(C2;A$2:A$39;0)>0;1;0)
The result of this will either be 1 (C2 is present in column A) or #Error (I tried getting 0 but this failed, no problem however).
This you can do three times, and you add the results, something like:
=IF(MATCH(C2;A$2:A$39;0)>0;1;0)
+IF(MATCH(C2;B$2:B$39;0)>0;1;0)
+IF(MATCH(C2;C$2:C$5;0)>0;1;0)
You divide the result by three in order for the successful result being equal to 1.
On that, you apply an IFERROR() function, translating the errors into 0.
Off you go :-)
If one has the new Dynamic Array formula:
=SUMPRODUCT(ISNUMBER(MATCH(UNIQUE(FILTER(C:C,C:C<>"")),A:A,0))*ISNUMBER(MATCH(UNIQUE(FILTER(C:C,C:C<>"")),B:B,0)))
No helper columns needed.

Counting decimal places using Excel gives weird result

I am trying to count the decimal places using a simple formula =LEN(A1-INT(A1))-2. The cell A1 is formated as Standard and contains e.g. the value 100.000739.
I don't understand why the formula returns 18 instead of 6?
=A1-INT(A1) ==> returns 0.000739 which is fine
=LEN(A1-INT(A1))-2 ==> returns 18
=LEN(0.000739) ==> returns 8 which is fine
Even if I explicitly formate the cell as a numer having 6 decimal places the formula still returns 18. Any idea?
Used version Microsoft Excel 2013
LEN returns the length of a string. A1-INT(A1) is a number, not a string.
Try
=T(A1-INT(A1)
and compare that with
=LEN(T(A1-INT(A1)))
That way you can see what value LEN is really using.
This works for me:
=LEN(A1)-FIND(".",A1)
if you have some integers in column A, then you will get an error as FIND will fail to find the decimal point. You can resolve that by first testing if the value in column A is an integer, and returning "0" in that case, like so:
=IF(A1=INT(A1),0,LEN(A1)-FIND(".",A1))

Excel min value greater than x returns 0 if no value found?

I am using the following formula:
=MIN(IF(A1:A5>B1,A1:A5)) use Ctrl-Shift-Enter
My value for B1 is 10 and my array is {1,5,4,2,7} so in this case no value is greater than 10.
The problem is that excel returns 0 as the result of the empty set which is a problem as 0 is not greater than 10.
In this case, I can test if the result 0 is greater than 10 and see that the result is invalid, however, if B1 is -10 for an array of {-15,-24,-11,-37-60} than the 0 seems like a valid value when no correct value exists.
So anybody know of how I can find the min or max value of a set with constraints, but return either an error or something distinct if the solution set is empty?
Thank you.
Try using SMALL instead of MIN, i.e.
=SMALL(IF(A1:A5>B1,A1:A5),1)
Unlike MIN the SMALL function will return an error [#NUM!] for your example
....or if you want a text value instead of an error then use IFERROR function, too, i.e.
=IFERROR(SMALL(IF(A1:A5>B1,A1:A5),1),"None")
Your IF statement will return False if none of the numbers in the range are greater than 10. It appears that MIN is converting False to numeric (0). You need to add behavior to handle the False.
If you know that all valid values must be >=0, then you could use the "else" section of the IF formula to return -1.
MIN(IF(A1:A5>B1,A1:A5,-1))

Resources