Excel extract and average values from column - excel

Is it possible if I have one column with names and another with pay. i.e.
John $120
John $100
Sally $90
Sally $100
Sally $80
to extract the values from column 2 for both John and Sally and then average them and place the results into two cells in another column? Could I use spreadsheet commands or do I need VBA to do this automatically.

You could use either
AVERAGEIFS (for xl07 and onwards)
A PivotTable see Debra's site for a good reference
If your data was in A2:B6 then this formula in D1 (with "John" in C1) works
=AVERAGEIFS($B$2:$B$6,$A$2:$A$6,D1)

If you need your spreadsheet to work with excel versions earlier than 2007, you can also use this formula:
=SUM(($D$1=$A$2:$A$6)*($B$2:$B$6)) / COUNTIF($A$2,$D$1)
This is an array formula, so you'll need to press CTRL+SHIFT+ENTER instead of just ENTER when entering it.
The formula works with the sample table in brettdj's answer, where
List of names is in A2:A6
List of values is in B2:B6
"John" is in D1
This formula goes into E1 (or anywhere, actually).
It works by calculating the sum of values in B2:B6 where the corresponding A2:A6 value is John, and then dividing it by the total number of Johns in A2:A6, which returns the average.

It works perfectly if you use semicolon (;) instead of comma (,) as it is below:
=AVERAGEIFS($B$2:$B$6,$A$2:$A$6,D1) - it doesn't work,
=AVERAGEIFS($B$2:$B$6;$A$2:$A$6;D1) - it works!

Related

Search multiple columns and return first row of column (header) if found

My goal is to get the header (first row in another sheet) if the value is found in the column.
Because VLOOKUP and HLOOKUP have some issues (e.g. search criteria has to be in the first column of the matrix), I have to find some alternatives. For VLOOKUP I'm using INDEX together with MATCH. Now I'm searching for an alternative for HLOOKUP. I found this post, but can't get it working.
I have two sheets:
column
Car Living Boat
----------------------------------
Kia appartment Jet-Ski
Chevrolet house speedboat
Ford condominium Yacht
Audi
search column
Original formula:
=INDEX(column!A1:C1;;MIN(WENN(column!A1:C5="speedboat";SPALTE(column!A:C))))
Converted formula:
=INDEX(column!A1:C1,,MIN(IF(column!A1:C5="speedboat",COLUMN(column!A:C))))
Currently the result of the above formula is Car. If I use the evaluate formula tool I can see, that the IF clause isn't evaluating the whole matrix, but I don't know why. What I'm doing wrong?
How can I get the header of the column?
The problem is you are using an array formula that needs to be confirmed through CtrlShiftEnter. You need to only do that once, and you are able to drag the formula.
If you don't want to enter through CtrlShiftEnter, an alternative to your formula could be:
=INDEX(column!A1:C1,SUMPRODUCT((column!A2:C5="speedboat")*(COLUMN(A2:C5))))
Or maybe even better:
=INDEX(column!A1:C1,MAX(INDEX((column!A2:C5="speedboat")*(COLUMN(A2:C5)),)))

Excel SUMPRODUCT w/ COUNTIF Between 2 Dates and 2nd Criteria

I have this formula:
=SUMPRODUCT((COUNTIF(A2:A1048576,ROW(INDIRECT(DATE(2019,1,1)&":"&DATE(2019,1,31))))>0)+0)
which will add up the unique occurrences between two dates. But I want to add a second criteria for a different column, lets say column "C" and it must contain lets say "TEST" in the cell. How would I modify this formula? I believe it uses COUNTIFS, but I can't seem to get the formula to work? Any help would be greatly appreciated! Thank you!
Date Quantity Notes
1/11/2019 2 OTHER Member Number Corrections
1/14/2019 7 TEST Member Number Corrections
1/14/2019 222 TEST Member Merges
1/15/2019 5 TEST Member Number Corrections
So the answer should be 2, they are both in January, 1/1/2019 - 1/31/2019 and they occurred on only two days, and the formula disregarded that there are blank cells at the bottom.

Two Names in Field

Currently, I am working with a scenario where I have 0 to 6 names in the field. For example, A2 has Bob Smith and Jone Random. Below is an example how they look in a check.
Effi Liu
<- (enter/gap)
Kevin Xing
Basically, I want to generate a 1 column that counts how many people in A2. For example, two people and then create a function that will separate. Each of the names into different columns.
If you have the names separated by the Enter Key in Column A, use the below formula in Column B and drag it to the right upto 6 or more cells and then drag down,
=TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1,CHAR(10),"#"),"#",REPT(" ",999)),(COLUMN(A:A)-1)*999+1,999))
This formula splits your name strings with the Enter Key as the delimiter into multiple columns as you drag. You could then use COUNTA function to find the non-blank cells (number of names). I leave that part to you to google and find it. Hope this helped you.

How to create a data validation list based on certain criteria and data from another workbook?

I have two Excel spreadsheet files (2 workbooks), one stores all the data, another wants to create a list based on certain criteria from the data in the previous workbook. Here are the two files:
File A:
A B
1 Chen China
2 Li China
3 Smith Britain
4 Tanaka Japan
5 Hironi Japan
On File B, I have two cells:
A B
China ?
Cell A1 is a list of countries such as China, Japan, etc. I have no problem creating this. But B1 needs to have a data validation list that reads data from File A. The list should not list all the items but based on the value of A1, say if A1 is China, B1 will have a list of two names: Chen and Li.
I can achieve it if all the sheets in the same workbook, but no matter how I tried, I couldn’t figure it out how to do that with separate spreadsheet files. I prefer using formula, but if necessary writing VBA code is also not a problem.
Thanks!
Not sure where you are with your formula but with a couple of tweaks this array should work, or at least provide a basis for you to solve your problem. The tweaks are (1) switch columns so the country is colA; (2) replace data file.xls and the sheet no. with your own; (3) drop the formula in B1 and drag it to (say) F1. Then you will need to edit the row reference in the formula by adding 1 each time i.e. the row ref in B1 will be ROW(1:1).... C1 will be ROW(2:2) etc
=IF(ISERROR( INDEX('[data file.xls]Sheet7'!$A$1:$B$5,SMALL(IF('[data
file.xls]Sheet7'!$A$1:$A$5=$A$1,ROW('[data
file.xls]Sheet7'!$A$1:$A$5)),ROW(1:1)),2)),"---", INDEX('[data
file.xls]Sheet7'!$A$1:$B$5,SMALL(IF('[data
file.xls]Sheet7'!$A$1:$A$5=$A$1,ROW('[data
file.xls]Sheet7'!$A$1:$A$5)),ROW(1:1)),2))
Remember this is an array formula so shift+ control+ enter. Hope it helps.

Excel - count running total based on a string value

I have a spreadsheet tracking e-mails received from various colleges. Column A is the name of the college, B is the date and C-F are other information about the e-mail. What I'm trying to figure out is how can I make column 'G' the total count of e-mails received from that college (i.e. count the # of occurrences of 'Drexel' in column 'A' when a new e-mail is received from Drexel).
I'd also like to figure out how to get the last date (column 'B') based on all e-mails from Drexel.
So my sheet might have 2,500 rows, and I add 2,501 as 'Drexel' and column G would show 74 as the total number received and H would show 10/1/2014 as the last e-mail received before the current one.
The count of emails from a particular college can be done with a COUNTIF() formula:
=CountIf(A:A, A2)
Where A:A is the column with the colleges, and A2 is the college on this particular row that you are searching for. This will return the number of times that particular college is listed in the spreadsheet.
Your second requirement to get the Max Date is a bit more tricky, and I believe it will require an Array Formula. These are written the same as a regular formula, but instead of hitting ENTER when you are done writing it, you hit CTRL+SHIFT+ENTER (sometimes also called CSE formulas):
=MAX(IF($A$2:$A$2500=A2, $B$2:$B$2500))
Put that in H2 and hit CTRL+SHIFT+ENTER, it will then get some squiggly brackets around it to let you know it's CSE/ARray formula (don't put the squiggly brackets in yourself. Only CTRL+SHIFT+ENTER will work here).
This formula will search through A2:A2500 comparing it to the college in A2. If it finds a hit, it will grab the value from the respective row in column B. At the end it will be a big list of dates, 1 for each entry where the college matches. The MAX() formula will then aggregate that list into a single value that will be the max date in the list.
Copy both of those formulas down your rows and you should get what you want.

Resources