I'm trying to calculate with an Array Formula (in Cell D2) what i'm calculating long-way in cell D11. The issue i'm having is that it appears my Array Formula is not evaluating the inputted array one-by-one. As an example, I want the second comparison that the formula does to be the following:
Check if ([B7>0] AND [C7=0]) and, if so, return D7.
But I think it's only checking to see if every value in the column B array is >0 and if every value in the column C array is =0.
The screenshot below details my problem. Thanks!
https://i.imgur.com/8eVp7X7.png
You don't need an array formula, you can use
=SUMIFS(B6:B10,B6:B10,">0",C6:C10,0)
Array formulas don't like AND. See here. This array formula would work
=SUM(IF(B6:B10>0,IF(C6:C10=0,B6:B10)))
Related
If you have a CSE array constant as follows in cell A1:
{={2,4,6,8}}
How can you get a specific element from the array constant? I tried the following formulas but they all return the first value of the array constant (2).
=INDEX(A1, 0)
=INDEX(A1, 1)
However, it does work if the array is not a reference. The following formula returns the 3rd element (6).
=INDEX({2,4,6,8},3)
Thank you
You could put the array constant in a Name instead of a cell.
Then INDEX will work with it properly with no implicit intersection.
Or you could parse the formula using the FORMULATEXT function, but that sounds tedious.
Try =INDEX(A1#,1). The # tells excel that A1 is a spill formula (more than 1 cell long). The array index starts at 1, not 0 in this case.
As a side note, Index knows you are referring to an index, not a row, when you give it a 1D array. In your example =INDEX(A1#,4) and =INDEX(A1#,1,4) return the Fourth item in your array (8 in this case), but =INDEX(A1#,4,1) will give you the error #REF!. If you define your array vertically {={2;4;6;8}}, =INDEX(A1#,4) and =INDEX(A1#,4,1) both work.
Edit: It looks like this does not always work in Excel 365 when a an array formula is created using Ctrl+Shift+Enter. I think this is due to the changes in 365. Array formulas have pretty much been replaced with spill formulas. Entering ={2,4,6,8} is mostly equivalent to a pre-365 array formula, but creating an array formula with Ctrl+Shift+Enter confines the output to as many cells as selected. In Dan's case, he selected only one cell and the formula doesn't automatically spill, so the formula is confined only to that cell. Excel seems to treat that cell as if it only contains that array element. If you select 2 cells and enter an array formula then =INDEX(A1#,2) will work but =INDEX(A1#,3) returns #REF!.
Edit2: It is possible with the FORMULATEXT Function as #DickKusleika suggested. Here is a function adapted from ExcelJet that does the job.
=LET(
DesiredIndex, 1,
ArrayFormulaRef, A1,
Formula, FORMULATEXT(ArrayFormulaRef),
FormulaLen, LEN(Formula),
CSVStart, FIND("{",Formula,2),
CSV, MID(LEFT(Formula,FormulaLen-1),CSVStart+1,FormulaLen),
TRIM(MID(SUBSTITUTE(CSV,",",REPT(" ",LEN(CSV))),(DesiredIndex-1)*LEN(CSV)+1,LEN(CSV)))
)
I am trying to obtain the value of a cell that is in a different sheet, from a formula that returns the value of the row where it finds a match.
Basically, what I'm trying to imitate is:
=Sheet!Column Row
But as follows
=Sheet!Column Formula (Which returns the row that meets the conditions of the formula)
The problem is that I tried concatenating the name of the sheet, the column and the result of the formula (row), which works, since I get, for example:
=Risks!K3
But that's all, I get a kind of string and in reality I would need that result to also be calculated by excel and return, precisely, the value of cell K3.
Is there any way to solve it?
Use INDEX:
=INDEX(Risks!K:K,formulathatreturns3)
E.g. I want to check if array (B1:B10) concatenated with (C1:C10) contains the text in cell A1, and if it does, return "Detected".
Some background info:
1) When those 2 arrays are concatenated together, they should have same length as A1.
2) Arrays concatenated with equivalent range value e.g. B1 with C1, B2 with C2.
EDIT
Using BigBen's template below, I tried =IF((MATCH(LEFT(A1,3),B1:B10,0)=MATCH(RIGHT(A1,3),C1:C10,0)),"detected","")
and managed to get the desired result; however, it does not account for duplicates 'bar' within column C.
enter image description here
enter image description here
IIUC, you can use MATCH for this:
=IF(ISNUMBER(MATCH(A1,B1:B10&C1:C10,0)),"Detected","")
IMPORTANT: Note that depending on your version of Excel, you may need to enter the formula with Ctrl+Shift+Enter.
This is probably very brittle, but given the data outline in BigBen's answer, this array formula (needs to be confirmed with Ctrl+Shift+Enter) returns the expected result:
=IF(ISNUMBER(SEARCH(A1,TEXTJOIN("|",FALSE,B1:B10&C1:C10),1)),"Detected","")
It basically joins each value in column B with the corresponding value in column C, then checks to see if the key word is detected in the resulting string. It is also dependant on you having a version of Excel that has the TEXTJOIN function.
Here is a view of the formula evaluation:
*note, I trimmed the data down to only 5 records, but you get it...
I have the below formula that Lookup the A1:A10 appropriated Score Number.
{=INDEX(Table1[ScoreNum],MATCH(A1:A10,Table1[ScoreWord],0))}
I need calculate the AVERAGE result of this entire array.
But when using this:
{=AVERAGE(INDEX(Table1[ScoreNum],MATCH(A1:A10,Table1[ScoreWord],0)))}
Returns the first looked up result with Index/Match, against returns the average of all returnable values whit this array formula.
How can do that?
The sample Workbook file
Sheet1
Sheet2: Table1
Note: The formula in B11 is: =AVERAGE(B1:B10) and returns the true value. I need return this without using the B helper column, directly in a single cell (A11) with the true form of formula shows in the picture.
Very truly yours.
Another method:
=AVERAGE(INDEX(Table1[Column2],N(IF({1},MATCH(A1:A10,Table1[Column1],0)))))
also entered as an array formula.
I would use, instead, this array-formula:
=AVERAGE(AVERAGEIF(Table1[Column1],A1:A10,Table1[Column2]))
To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.
The AVERAGEIF function returns the array {1;0.8;1;0.2;0.6;0.8;1;1;0.6;0.2} which is what you are showing in your column B in your screenshot.
We then AVERAGE that array by nesting the AVERAGEIF(.. within the AVERAGE function.
I am trying to get the max value of a column based on the Left function
What I am doing is the following :
These are the results I get when i write this into column C :
=MAX(LEFT(A:A, 2))
But what I truly want is to get in column C the max value of all column A not for each cell.
So the result should be in this case 90 for all rows.
What should be the formula here?
Just another option that gets entered normally:
=AGGREGATE(14,6,--LEFT($A$1:INDEX(A:A,MATCH("ZZZ",A:A)),2),1)
Array formulas will calculate the enitre referenced array. So care should be taken to limit the number of iterations to only the data set.
The $A$1:INDEX(A:A,MATCH("ZZZ",A:A)) part of the formula does that. It finds the last cell in column A with data in it and sets that as the upper bound. So in this instance the reference range is A1:A3. But, it will grow dynamically as data in Column A is added, so no need to change the formula each time data is added.
Update 2
Here is another solution which I think is better than my original (below)
=INT(SUMPRODUCT(MAX(SUBSTITUTE(A:A,"-",".")*1)))
it can be entered as normal (just Enter)
Orignal Answer
You need numbers and arrays
=MAX(IFERROR(LEFT(A:A,2)*1,0))
Let's break this down. Multiplying by turns your strings into numbers - since Left only returns a string
LEFT(A:A,2)*1
Unfortunately this method returns #Value if you multiply an empty string by 1. You will definitely have some empty strings in the range A:A so we wrap the whole thing with an IFERROR function.
IFERROR(LEFT(A:A,2)*1,0)
Now we still need excel to treat this as an array (i.e. a whole column of numbers, rather than just one number). So we put the MAX formula in and enter it with Ctrl+Shift+Enter rather than just Enter. The result is that the formula looks like this in the formula bar
{=MAX(IFERROR(LEFT(A:A,2)*1,0))}
which would return 90 in your example, as required
Update 1
If you are using Excel 2013 or later, you can also use the NUMBERVALUE function
=MAX(NUMBERVALUE(LEFT(A:A,2)))
again, enter it with Ctrl+Shift+Enter