May I know what is the meaning of this formula used in one of my worksheet:
=IF(COUNTA(INDIRECT(F3))-3<0,1,COUNTA(INDIRECT(F3))-3)
INDIRECT(F3) takes the contents of cell F3 and uses it as a Range value.
COUNTA counts the number of non-empty cells in the range
The IF function evaluates the boolean expression in the first parameter. If it evaluates to True, it returns the result of the expression in the second parameter. If the first paramater evaluates to False,
So this formula looks at the range specified in F3 and counts the number of cells that are not empty. If that count minus 3 is less than 0 then it returns 1. Otherwise it returns the count minus 3.
Related
Why does this hlookup function return 0?
A1 = 2, B1 = 0, C1 = 0
=hlookup(3,A1:C1,1,true)
Reading the description here: https://support.microsoft.com/en-us/office/hlookup-function-a3034eec-b719-4ba3-bb65-e1ad662ed95f, it says for the range parameter (the last parameter):
"If TRUE or omitted, an approximate match is returned. In other words, if an exact match is not found, the next largest value that is less than lookup_value is returned"
The next largest value is 2 (in A1) which is less than the lookup value (3).
Using MS Office 365 Apps for enterprise
HLOOKUP will require that the values be sorted when using TRUE:
https://support.microsoft.com/en-us/office/hlookup-function-a3034eec-b719-4ba3-bb65-e1ad662ed95f#:~:text=If%20range_lookup%20is%20TRUE%2C%20the%20values%20in%20the%20first%20row%20of%20table_array%20must%20be%20placed%20in%20ascending%20order
But we can use MAXIFS if they are numbers:
=MAXIFS(A1:C1,A1:C1,"<="&3)
OR XLOOKUP which does not care if sorted or not.
=XLOOKUP(3,A1:C1,A1:C1,"",-1)
The HLOOKUP function returns 0 because the value 3 is not found in the lookup range A1:A3. The HLOOKUP function performs a horizontal search, i.e., it searches for the lookup value vertically in the first row of the lookup range.
Since the lookup value 3 is not found in the range A1:A3, which only contains the values 2, 0, and 0, the HLOOKUP function returns the value specified in the result_vector argument, which in this case is 1. When the value is not found and the range_lookup argument is set to True (which it is in this case), the HLOOKUP function returns the closest match that is less than the lookup value. In this case, since there is no match, it returns 0.
{=MEDIAN(IF(ISNA(INDEX(ASpreadDataBlocDisplay,ADaysIndex,,1)),"~",INDEX(ASpreadDataBlocDisplay,ADaysIndex,,1)))}
ADaysIndex is single column range with the number sequence 1,2,...271. The numbers are the row numbers. Entered as array, this formula always returns the first row of the range "ASpreadDataBlocDisplay", i.e. "ADaysIndex" always returns "1". Is there a method to force the function to return the "ADaysIndex" as a sequence?
N.B. The formula evaluates correctly if I use a simple cell reference like B15.
Cheers
in column A first value is 0, second is 0, third is 17, fourth is 0 and fifth is 32
in this case , first non zero value is 17. how to calculate it by formula
In cell B1:
=INDEX(A1:A5,MATCH(TRUE,INDEX(A1:A5<>0,),0))
Explanation for the above formula:
The inner Index function evaluates the values in the A1:A5 range to either TRUE or FALSE based on the specified condition, that is, not equal to 0. So 17 and 32 evaluate to TRUE, everything else to FALSE. The Match function returns the row number where the first instance of the specified condition TRUE is. This occurs on the 3rd row of the range, so Match evaluates to 3. Finally, the outer Index functions returns the value at row number 3 in the specified A1:A5 range, which is 17.
I have seen the formula =IF(SUMPRODUCT(($A$2:$A2=A2)*($B$2:$B2=B2))>1,0,1) in here
I am confused about this equal sign = ... What is it for ?
It is used for comparison.
If the range $A$2:$A2 is equal to A2, then it evaluates to TRUE.
It's similar if you type in a cell =2=2, you'll get TRUE as result, except the one in your question is comparing a range with a single cell.
Anchoring the top row of the range with $A$2 but allowing it to expand by not anching the row in the second cell reference allows to to have one instance where the sumproduct() will return only one value. If the full range was included in all cells, any value that occurred two or more times would have a 0 value returned.
I have a row of values - 1,2,3,8,35,7,8,3,5,7,x
X is where I want the formula to be
I'd like to somehow get the value of the row which 8 is the closest to X (so not row 4 in this case, but row 7)
If I use match("8",A:A,0) I get the first match it finds.
How do I find the closest match to the cell where the calculation occurs?
You may use:
{=MATCH(2,1/(A1:A10=8))}
just remember it is an array function, so CTRL+SHIFT+ENTER must be used
The answer is based on a trick and behaviour of the MATCH function. I will allow myself to copy the explanation from ozgrid:
The magic here is actually in the MATCH function more than the array. Two interesting properties of the match function are being used here:
1) With MATCH, if no match is found, then the function will return the position of the last value in the array, so if you did =MATCH(8,{1,2,3,4,5,6,7,6,5,4,3,2,1}), your result is = 13, since there was no 8 to find in the array
2) MATCH will return the position of the last value, but won't return the position of an error (or of a blank value), so if you have =MATCH(8,{1,2,3,4,#DIV/0!,#DIV/0!,7,6,5,4,3,#DIV/0!,#DIV/0!}), your result is = 11, as the 3 in the 11th position is the last value in the array
So daddylonglegs' formula checks each cell against the target value with (A1:A13=B1) in the array formula, giving an array with TRUE (or 1) for the positions where the cells match, and with FALSE (or 0) for the rest. Dividing 1 by this results in 1s wherever that array was TRUE, and #DIV/0! wherever that array was false. So his formula is evaluated as
=MATCH(2,{#DIV/0!,1,#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!,1,#DIV/0!,1,#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!})
Since no '2' is found in the array, and the last value (1) is found in the 9th position, the MATCH returns 9
If you want the last match you can use this formula in A11
=MATCH(2,INDEX(1/(A1:A10=8),0))
[Note: if the values are numeric then 8 is OK - if they are text formatted numbers then you need "8"]
....or do you have values either side of the calculation cell (so nearest might be up or down)?