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.
Related
I want to get the sum of the text inside (<number>) like the table below
tried this formula but this does not work or throws an error
{=SUMIF($D1:$D7, $F1&"(*", -RIGHT($D1:$D7, 3))}
RIGHT works okay with SUM like this formula
{=SUM(-RIGHT(D1:D7,3))}
The SUMIF function takes the following parameters:
the range of cells to inspect
the criteria
the range of cells to sum
So the third parameter MUST be a range of cells.
But -RIGHT($D1:$D7, 3) doesn't return a range of cells - it returns an array of values.
That means SUMIF isn't the right tool. Instead, make your {=SUM(-RIGHT(D1:D7,3))} array formula conditional by multiplying each value by one or zero based on the values in F:
{=SUM( (LEFT(D$1:D$7,2)=F1) * (-RIGHT(D$1:D$7,3)) )}
This is an array formula so must be entered by using Control-Shift-Enter instead of just Enter alone. Put it in G1 and then copy it down to the other cells.
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 have some data of transactions, for example as following:
Column B|Column C
TRUCK_ID|TON
TR-12 |60
TR-10 |65
TR-09 |56
TR-12 |75
TR-10 |70
*in reality I have thousands data
Then I would like to count how many truck that loads overcapacity, where
the load limit as following:
Column F|Column G
TR-09|50
TR-10|60
TR-12|65
I use a combination of SUM, IF, INDEX, MATCH and ROW
=SUM(IF(C4:C8>INDEX(G4:G6,MATCH(INDEX(B4:B8,ROW(B4:B8)-3),F4:F6,0)),1))
But when I only select one (single) cell and click CSE
it returns '2' (incorrect)
If I select multi cells (let say 2 cells) and click CSE
it returns '4' (correct)
I expect I only put and select one single cell only and return the correct result. Anybody could help me, please
You could try:
=SUMPRODUCT((B2:B6=TRANSPOSE(F2:F4))*(C2:C6>TRANSPOSE(G2:G4)))
Note: This is an array formula and need to be confirmed through CtrlShiftEnter
You could also add one helper column, in H2 put:
=COUNTIFS($B$2:$B$6,F2,$C$2:$C$6,">"&G2)
And drag down, to sum H2:H at the end.
Screenshot SUMPRODUCT:
Screenshot Helper column:
EDIT#2
Try modify your original formula as below:
=SUM(IF(C4:C8>INDEX(G4:G6,MATCH(INDEX(B4:B8,N(IF(1,ROW(B4:B8)))-3),F4:F6,0)),1))
Use N and IF function can actually overcome the issue of INDEX only returning the first value from the range in a single cell.
Alternatively, suppose you have the following named ranges:
Truck_ID being data in Column B;
TON being data in Column C;
List_ID being data in Column F;
List_TON being data in Column G.
You can use the following formula to return the desired result 4 presume the look-up table is sorted in ascending order:
=SUMPRODUCT(--(LOOKUP(Truck_ID,List_ID,List_TON)<TON))
or
{=SUM(IF((LOOKUP(Truck_ID,List_ID,List_TON)<TON),1))} 'Entered by CSE as array formula
Your INDEX function INDEX(G4:G6,MATCH(INDEX(B4:B8,ROW(B4:B8)-3),F4:F6,0)) is returning a single-column array, which will only return the first value from the array which is 65 in a single cell. So your full formula is essentially comparing each value in TON against 65. As a result there are only 2 values that are greater than 65. As shown in Column D of my example, a more proper use of INDEX in this case would be highlighting range D4:D8 and enter the array formula as shown in the formula bar. Then you can do a SUM for all TRUE results. If you enter your full formula in multiple cells, your INDEX formula will actually return the full array instead of the first value so the comparison will return the correct result.
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)))
I have searched the Net and tried multiple solution which never worked. You are my last hope.
I have a table like that:
NAMES.......... VALUES
A...........................4
A...........................1
B...........................4
B...........................3
B...........................2
B...........................1
C...........................4
C...........................3
As you can see, the first column has names only where the second one values.
Both Names and Values often repeat them self.
The idea is to TAG the names (first column) with the MIN value taken from the second column.
So the correct result should be:
NAMES.......... VALUES
A...........................1
B...........................1
C...........................3
I am trying to do that through Excel using the INDEX+Match formula where I am trying to add a MIN formula without success:
=MIN(INDEX($D$25:$D$36,MATCH(C25,$C$25:$C$36,0),1))
I have put the MIN everywhere but none seems to work. Which is the correct syntax and if this is not the right solution, which formula might do the job?
Thank you for your time and help
With data in column A and B, in C1 through C3 enter:ABC then in D1 enter the array formula:
=MIN(IF(A$1:A$100=C1,B$1:B$100,""))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
If the data never changes, a Pivot Table is easier to implement.
Two non-array alternatives.
With the newer MINIFS function.
=minifs(d:d, c:c, c25)
Using INDEX in its array format but entered as a standard formula,
=min(index((d$25:d$36)+(c$25:c$36<>c25)*1e99, , ))