In Excel, how to find a average from selected cells - excel

Need your help.
I have an excel sheet with two columns, like this:
I would to find an average of the number in the cells from column 2 that correspond to the numbers in column 1 which end either in 2 or 5. If column 2 has a blank cell or a letter, it should be ignored.

If one has the dynamic array formula FILTER():
=AVERAGE(FILTER(B2:B15,ISNUMBER(MATCH(--RIGHT(A2:A15),{2,5},0))))
If not then use this array formula:
=AVERAGE(IF(ISNUMBER(MATCH(--RIGHT(A2:A15),{2,5},0)),B2:B15))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

Related

How to INDEX MATCH return multiple words between sheets

In sheet 1 column 1 is a vertical list of words (e.g. A1:A25).
In sheet 1 column 2 I want to randomly put multiple X’s (e.g. in a few cells between B1:B25).
In sheet 2 I want to return whatever words are to the left of the X’s in sheet 1. How would I do this?
Im currently returning one word using the following formula:
=INDEX(Sheet1!A1:A25,MATCH("X",Sheet!B1:B25,0))
What formula would return multiple words to sheet2 from column 1 of sheet1 (via X’s in the second column of sheet1)?
With the dynamic array formula available in Office 365, use FILTER:
=FILTER(Sheet1!A:A,Sheet1!B:B="X")
Put that in the first cell and the results will automatically spill down.
With older versions, put this in the first cell and copy/drag down:
=IFERROR(INDEX(Sheet1!A:A,AGGREGATE(15,7,ROW(Sheet1!$B$1:$B$25)/(Sheet1!$B$1:$B$25="X"),Row($ZZ1))),"")

Calculate correlation in Excel after matching on a column

I need to calculate correlations for multiple years. The trick is in selecting appropriate rows from 2 columns after matching values a third column.
Use the CORREL() formula as an array formula:
=CORREL(IF($A$2:$A$12 = E2,$B$2:$B$12),IF($A$2:$A$12 = E2,$C$2:$C$12))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

I need to find an excel formula that I can use to create a unique list of Item numbers from an array

I need to find an excel formula that I can use to create a unique list of Item numbers from an array. I do not want to count them I just want to make a list of the Item Numbers. These part numbers are actually Alpha Numeric and can have repeating numbers through out the array multiple times. There is one other catch this list will have empty cells in it and could also be the first record in the array. This data is being pulled into Excel through a Jet report add-in for Excel.
Example: Starting in cell A1..A9
Item No.
<BLANK>
7810042050
783979
7810006045
7810006042
7810006032
<BLANK>
7810006022
7810006032
With values in column A, in C1 enter:
=MAX(A1:A10)
in C2 enter the array formula:
=MAX(IF(A$1:A$10<C1,A$1:A$10,""))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
EDIT#1:
Chris Neilsen has pointed out that the values in column A are actually Text rather than Numeric. To accommodate this, two changes must be made to the formulas:
A1 must be excluded
the alphas must be converted to numeric.
So we will replace the normal formula:
=MAX(A1:A10)
with the array formula:
=MAX(--(A2:A10))
and replace:
=MAX(IF(A$1:A$10<C1,A$1:A$10,""))
with the array formula:
=MAX(IF(--(A$2:A$10)<C1,--(A$2:A$10),""))
and then copy down.
If you have alpha characters in the part numbers you can do this in 2 steps.
Both are array formulas and you need to use Ctrl-Shift-Enter
Col B - sorted list of items in Col A
B2 =IFERROR(INDEX($A$2:$A$10,MATCH(COUNTA($A$2:A2),COUNTIF($A$2:$A$10,"<="&$A$2:$A$10),0),1),"")
Col C - eliminate the duplicates
C2 = IFERROR(INDEX($B$2:$B$10, MATCH(0, COUNTIF($C$1:C1, $B$2:$B$10), 0)),"")
Copy both formulas down.
I tried to combine the two formulas but nesting an array (results in Col B) with varying row ranges did not work out. I could not find a way but the two formulas together will work.
Enter this Formula Array in B2 and copy to B3:B10
FormulaArrays are entered pressing [Ctrl] + [Shift] + [Enter] simultaneously, you shall see { and } around the formula if entered correctly
=IFERROR(
INDEX($A$2:$A$10,
MATCH(1,1+COUNTIF($B1:$B$1,$A$2:$A$10)+(($A$2:$A$10="")*1),0)*1),"")

excel formula to add cells in a single row based on criteria

Let's say,
Sheet1:A1 = x
Sheet2 contents look like
x 3 3 4
y 0 2 1
Is there an excel formula that could match Sheet1:A1 with Sheet2:A1 (basically the value 'x') and add the other cells in that row (3,3,4). The result (Sum='10') should get updated at Sheet1:C4 lets say.
I tried SUMIF but that shows the content of only one column due to the restriction that it can handle only the matchable array size. I know this can be achieved through VBA, but just wanted to know if a formula is available.
TIA!
This formula will do what you want:
=SUM(SUMIF(Sheet2!A:A,A1,INDIRECT("Sheet2!" & {"B:B","C:C","D:D"})))
It will iterate through the columns doing individual SUMIF() on each and then adding the results.
If you want more columns or different change the address in the array to the columns desired.
Try the following
=SUM(IF(Sheet2!A1:A99=A1,Sheet2!B1:D99,0))
Note that this is an array formula, so it must be entered using Ctrl+Shift+Enter.
What this formula does is converts any rows on Sheet2 without x in column A to zeros in B:D and then sums what is left.
Similarly, you could use
=SUMPRODUCT((Sheet2!A1:A99=A1)*Sheet2!B1:D99)
and you wouldn't have to enter it as an array formula.
For a non-volatile, non-array formula, try this
=SUM(INDEX(Sheet2!B:D,MATCH(Sheet1!A1,Sheet2!A:A,0),))

Excel - Count cells according to occurrence

In the above eg- it should show the count value - 8
This requires an array formula. To enter an array formula, enter the formula into a cell and then hit Ctrl+Shift+Enter.
=SUM(IF(COUNTIF(OFFSET(A1:C5,ROW(A1:C5)-1,0,1,3),"<>""")>0,1,0))
Put this formula in D1:
=IF(COUNT(A1:C1)>0,1,0)
Copy the formula down for as many rows as you have.
Take the sum of column D.

Resources