I feel a bit embarrassed for asking this but here goes:
I'm using Excel 2010 and I have a worksheet containing 700+ customer satisfaction survey responses. Each row is a survey with a 1-5 or NA response to 5 questions. It looks like the following:
+-Agent--+--Q1--+--Q2--+--Q3--+
| | | | |
| Jeff | 5 | 5 | 5 |
+--------+------+------+------+
| James | 1 | 1 | 1 |
+--------+------+------+------+
| Jack | 5 | 5 | 5 |
+--------+------+------+------+
| Jeff | 3 | NA | 5 |
+--------+------+------+------+
| Jeff | NA | NA | 3 |
+--------+------+------+------+
| James | 5 | 5 | 5 |
+--------+------+------+------+
| ... | ... | ... | ... |
+--------+------+------+------+
I want to create a worksheet listing each agent in column A and the average of all of questions answered regarding them. I tried a formula like AVERAGEIF(SurveyResponses!A2:A7,A2,SurveyResponses!B2:D7) where A2 contains the agent's name, but it doesn't appear to work properly.
For example, I get a 5.00 average for some agents when it should be a 4.61. When I look in the Function Arguments screen for my AVERAGEIF on this person, it looks like it recognizes the values properly. The Average_rage shows {"NA","NA","NA","NA",1;5,5,5,5,5;5,... but the returned value below that says = 5 which is not right since there is a 1.
Can anyone guide me in the right direction?
AVERAGEIF works like SUMIF, the second range used is actually the same size and shape as the first range, starting with the top left cell, so when you use this
=AVERAGEIF(SurveyResponses!A2:A7,A2,SurveyResponses!B2:D7)
because the first range is a single column then the second range used must be too (there's a 1 to 1 relationship between the cells) so because the top left cell in SurveyResponses!B2:D7 is SurveyResponses!B2 the range begins there and is the same size and shape as SurveyResponses!A2:A7
....so you are actually getting this....
=AVERAGEIF(SurveyResponses!A2:A7,A2,SurveyResponses!B2:B7)
AVERAGEIF help does tell you that but it isn't very clear
If you want the ranges to be different sizes you need an "array formula" like this
=AVERAGE(IF(SurveyResponses!A2:A7=A2,SurveyResponses!B2:D7))
You need to confirm that with CTRL+SHIFT+ENTER so that curly braces appear around the formula in the formula bar. That formula will count any blanks as zeroes but ignore text values like NA
Easiest way to do this would be a pivot table. They look scary, but they're fairly easy to use. Rows = names, Columns = Q, Average for the answers.
Related
I don't know if I am missing something obvious or what, but I cannot wrap my brain around what I need from this. I have a table with products available for sale and various criteria. I have a second table with a smaller list of stores and a second column of whether I should include them in my results set. In this example, I would never include store 789, but I might include 123 and/or 456, depending on whether an "x" was placed in that second column.
So, for my results, I would break them out by Product and color with a simple SUMIFS statement. However, I really want to be able to filter the sites out if they are "x" on that second tab. Any thoughts on how I could easily do that? I did insert a column on my raw data sheet and just added an if statement, then I used that as a 4th criteria in my SUMIFS, but I was looking for a more elegant solution.
I can get either matching stores or the rest of the filters, but I cannot figure how to make both work together in the same statement or how to include them if they are "x"-ed.
This will get me the filtered stores
=SUMPRODUCT(SUMIF('Tab1'!A:A,'Tab2'!A:A,'Tab1'!D:D))
Either of these will get me the filtered products:
=SUMIFS('Tab1'!D:D, 'Tab1'!B:B, A2, 'Tab1'!C:C, B2)
=SUMPRODUCT(--('Tab1'!B:B=A2), --('Tab1'!C:C=B2), 'Tab1'!D:D)
Tab1
Store | Product | Color | Sales
--------------------------------
123 | A | Red | 1
123 | A | Blue | 2
123 | B | Red | 4
456 | A | Blue | 8
456 | B | Red | 16
789 | A | Red | 32
789 | B | Red | 64
Tab2
Store | Include
---------------
123 |
456 | x
Results:
Product | Color | Sales
------------------------
A | Red | 0
A | Blue | 8
B | Red | 16
Why not use VLookUp's to add the column from Tab2 to Tab1?
For example, new Column E, to the right of Sales:
=VLookUp(A1, "Tab2", 2, False)
...and fill-down?
You could base SumIf criteria on multiple tables but personally I'd just keep the data together (dynamically) just to make it easier and neater.
Build a pivot table and use slicers to include or exclude specific data. Then you don't need a helper table and you don't need formulas, either. Just a few clicks.
I want excel to count the FREQUENCY that certain number-letter combinations appear down a column in excel (using vba). All my data goes down one column like this:
Column A (only 1,2,3,4,5,s,f appear)
1
2
s
4
3
s
4
2
f
2
s
2
s
I want to count the number of occasions combinations of (1-s, 2-s, 3-s, 4-s, 5-s) occur, strictly when the number occurs first (is in the higher row). I do not want to count occasions when the s comes before the number (e.g. s-2). I know how to count the number of individual letters/numbers using the countIf function.
I might later want to expand my analysis to look at the occasions that three letter-number combinations (e.g. 2-s-3, 2-s-5)
I am very much a VBA noob.
Try inserting a new column to the right of Column A. Use this formula =A1&A2 and fill it down the column. The values will look like this:
+----------+----------+
| Column A | Column B |
+----------+----------+
| 1 | 12 |
| 2 | 2s |
| s | s4 |
| 4 | 43 |
| 3 | 3s |
| s | s4 |
| 4 | 42 |
| 2 | 2f |
| f | f2 |
| 2 | 2s |
| s | s2 |
| 2 | 2s |
| s | s |
+----------+----------+
Now you can count occurences like you were doing before! :D
Of course, you can expand to three character frequency analysis by making the formula =A1&A2&A3.
Seems possible with COUNTIFS, with 1 to 5 inclusive in C1:G1 and in C2:
=COUNTIFS($A1:$A12,C1,$A2:$A13,"s")
copied across to suit.
You can use the VBA equivalent of this formula
=SUMPRODUCT(--(ISNUMBER(A1:A12)),--(A2:A13="s"))
which looks for number, followed by s in the row below (4 for your sample)
code
MsgBox Evaluate("SUMPRODUCT(--(ISNUMBER(A1:A12)),--(A2:A13=""s""))")
So basically, I have two columns, in two different worksheets that I need to add together.
This may be best explained with an example:
WORKBOOK 1
A B
_____________________________
1 | Unique ID | Number
2 | B1 | 2
3 | C0 | 10
4 | D9 | N/A
5 | 9L | 0
6 | 12 | 5
WORKBOOK 2
A B
_____________________________
1 | Identifier | Price
2 | Q9 | $10.00
3 | 9L | $5.00
4 | B1 | $299.00
5 | C0 | $0.99
6 | 12 | $100.00
The columns in wordbook 1 are named unique_id and price and the columns in workbook 2 are named identifier and number.
Is it possible to do something such as - If unique_id from the first workbook is equal to an identifier within the second workbook, multiply the number and price together. This has to be done for each column/row, and it should somehow either skip or treat the N/A as nothing/zero.
Is something like this possible without the use of macros, and just by using a simple function within a cell? Or is there a far better method than what I am thinking of?
Please try:
=VLOOKUP(A1,[book1]Sheet1!$A:$B,2,FALSE)*B1
copied down to suit.
This approach will work if your columns are sorted. You may be able to build upon it:
=SUMPRODUCT(B2:B6,SUMIF(A2:A6,[Book2]Sheet1!$A$2:$A$6,[Book2]Sheet1!$B$2:$B$6))
The resulting value is 1107.90
What I am Trying to do is
lets say I have a excel sheet with
rows
ProductNo | Product | Sku | Price | Image | Thumb
25 | Shirt Blue | 4251 | $10 | shirt.jpg | shirtthumb.jpg
2 | Shirt Green | 4581 | $17 | green.jpg | greenthumb.jpg
8 | Shirt Black | 4561 | $15 | black.jpg | blackthumb.jpg
and just in different rows or on another excel sheet
ProductNo | Product | Sku | Price | Image | Thumb
25 | Shirt Blue | 4251 | $52 | |
2 | Shirt Green | 4581 | $42 | |
8 | Shirt Black | 4561 | $65 | |
How can i change the first table to update if the the second table or sheet columns data is different on specified columns and if the cells are empty forget about them ignore them and just replace the values from the second table onto the first
Final would be
ProductNo | Product | Sku | Price | Image | Thumb
25 | Shirt Blue | 4251 | $52 | shirt.jpg | shirtthumb.jpg
2 | Shirt Green | 4581 | $42 | green.jpg | greenthumb.jpg
8 | Shirt Black | 4561 | $65 | black.jpg | blackthumb.jpg
I have tried a couple of excel functions but they do not work since i have so many products to be doing cell additions
I tried doing in Vl but got confused and macro i dont even know what it is
Im open to whatever visual, functions just as long as i can perform the task
if anybody know hos let me know
Thank You
in stead of having the fixed values I propose you use a permanent formula in the specified columns.
Now to do this I would use a VLOOKUP() function. I am assuming that your ProductNo is the element that never changes therefore all the other columns will get a VLOOKUP() function.
Now if I understand correctly you MIGHT have an update in the 2nd table for the 1st table, but any empty cells in the 2nd table should be ignored.
I am also assuming you wish to see when an element will change because of the update therefore I propose the following:
In the first table add for the block of columns elements that might need an update: 2 blocks of columns, the first with the result of combining (the COMB-block) and the second with lookups from the 2nd table (the LOOKUP-block). For convenience of explaining I put the two tables in the same workbook on the sheets called table1 and table2
ProductNo | Product | Sku | Price | Image | Thumb | Product_comb | Sku_comb | Price_comb | Image_comb | Thumb_comb | Product_lookup | Sku_lookup | Price_lookup | Image_lookup | Thumb_lookup
Now start with formulas in the LOOKUP-block, use VLOOKUP(), such as this one for the *Product_vlookup* column:
=IFERROR(VLOOKUP($A2,table2!$A:B,COLUMNS(table2!$A:B),FALSE),"")
The IFERROR is for the case the product in table1 cannot be found in table2
For the formulas in the COMB-block the following will prefer the table 2 result over the table 1 result. As VLOOKUP of a matching ProductNo with an empty Element (for example for the Image) will result in a 0 (zero) returned all zeroes are regarded false lookup results as well. This is the script for the *Product_comb* column:
=IF(OR(ISBLANK(L2),L2=0),B2,L2)
As a final step to identify the products that changed you can either add a column that compared the original value with the _comb value:
=AND(B2=G2,C2=H2,D2=I2,E2=J2,F2=K2) (this returns true for no changed columns and false for any changed column)
Or use conditional formatting on each element separately or on the combination as the AND() formula shows.
As a final step in your process of updating you could copy all records from the COMB-block and paste it over the original elements.
If you have any further questions please ask.
First off, I'd like to do this without VB if possible, so I don't have to go through the hassle of teaching recipients how to enable macros.
Now, I believe what I'd like to do is simple, but the answer may be complex formula-wise. I'm trying to list out in new columns the values from a specified column in rows which have matching values from two other columns. Sounds tricky I'm sure, but an example should help immensely...
Say I have the following data:
------------------
| sts | pos | bye |
------------------
| 0 | QB | 8 |
| 2 | WR | 3 |
| 2 | QB | 10 |
| 0 | QB | 4 |
| 2 | QB | 7 |
| 0 | WR | 11 |
| 2 | WR | 9 |
| 2 | QB | 5 |
------------------
That's my source. I want to list out the bye value from all rows that have sts = 2, for each respective pos. In other words, from the source data above I'd want to see the following result set:
--------------------------
| pos | byes |
--------------------------
| QB | 10 | 7 | 5 | |
| WR | 3 | 9 | | |
--------------------------
...because those are the bye values in the rows with sts = 2 and pos equal to the corresponding pos in the result table.
Again, I'd like to avoid macros if possible, and just use a formula in the bye cells of the results table.
Hopefully that makes enough sense for you to take a stab at it. Thanks!
FOLLOW-UP:
#Richard-Morgan I attempted to use your formula but can't get it to work. Here is a screenshot of my actual spreadsheet so we can use real cell references:
So sts is B2:B303, pos is D2:D303, and bye is E2:E303. So then I'd like to list out the byes in columns U thru Y. It looks like your answer, if I'm smart enough to implement it, will get me what I need, so any assistance you can provide to get me to the finish line is greatly appreciated!
Something along the lines of the following could be used:
{=INDEX(tbl, SMALL(IF(COUNTIF(G$3, $A$2:$A$9)
*COUNTIF(G$4, $B$2:$B$9), ROW(tbl)-MIN(ROW(tbl))+1), ROW($C1)), COLUMN($C1))}
where the A column is sts, B column is pos, and C column is bye. The variable tbl is the range of data (not the headers). G$3 would be the sts filter and G$4 is the pos filter.
Copy the array formula DOWN to find all the matching byes; #NUM! will appear after finding no more matches. If this bothers your users, you can add an ISERROR or a tricky conditional format that makes the text white on white.
You can then copy over the formula to the next column and enter new filter values.
G H
sts Search 2 2
pos Search QB WR
10 3
7 9
5 #NUM!
#NUM!#NUM!
If your users are comfortable with pivot tables, using them would be much easier, I would think.
EDIT
Making the formula "transpose" is a bit tricky and I am not having any breakthrough on how to fix that. However, if you want to manually edit the column formulas, here is what you want.
(I made the assumption that S is the sts filter. Maybe you're just doing a count there, but I didn't see where you enter the filter for sts. If S isn't the sts filter, update the formulas to point to where sts is 2 or whatever.)
U2:
{=INDEX(tbl, SMALL(IF(COUNTIF($S2, $B$2:$B$303)*COUNTIF($R2, $D$2:$D$303),
ROW(tbl)-MIN(ROW(tbl))+1), ROW($D$1)), COLUMN($D$1))}
V2:
{=INDEX(tbl, SMALL(IF(COUNTIF($S2, $B$2:$B$303)*COUNTIF($R2, $D$2:$D$303),
ROW(tbl)-MIN(ROW(tbl))+1), ROW($D$2)), COLUMN($D$2))}
etc.
This allows the cells to be copied down.
I am sure there is a way to INDIRECT the ROW/COLUMN, but I ran out of time to look at this at the moment.
EDIT 2
If you put a simple number increment somewhere, let's say U1 has 1, V1 has 2, W1 has 3, etc., you could use the following:
{=INDEX(tbl, SMALL(IF(COUNTIF($S2, $B$2:$B$9)*COUNTIF($R2, $D$2:$D$9),
ROW(tbl)-MIN(ROW(tbl))+1), U$1), COLUMN($D$1))}
This will copy down and across.
This sounds like a job for pivot tables and go to special. You need to add an ID # column though. Here is one way you could do it:
Then once the blanks are selected using go to special you just need to delete them and shift cells left.
Good Luck.
OK I figured out a way to get my desired results. It isn't the cleanest or best way, but it achieves my goal of listing the results horizontally, and avoids macros or pivot tables.
I use a hidden worksheet to list out all the pos and sts values, concatenated as a single value. So...
sts | pos | bye
----------------------
2 | QB | 8
2 | RB | 5
2 | QB | 11
0 | WR | 7
. . .
...becomes....
D | E
-----------
5 | 2QB | 8
6 | 2RB | 5
7 | 2QB | 11
8 | 0WR | 7
. . .
Then, I have a "shadow" results area that mimics the results area on my front-page worksheet. It looks like so:
G | H | I | J | K
-----------------------------
5 | QB | | | | |
6 | RB | | | | |
7 | WR | | | | | . . .
In H5:H7, I have the following formula:
=IFERROR((ADDRESS(MATCH("2"&$G5,$D$5:$D$305,0)+4,COLUMN($E5),4)),"")
This returns the first cell reference it finds in the concatenated column that starts with 2 and ends with the value in column G (e.g. the formulas in row 5 are looking for "2QB").
Then, in I5:n7 I have the following modified formula:
=IFERROR(ADDRESS(MATCH("2"&$G5,INDIRECT(ADDRESS(ROW(INDIRECT(H5))+1,4)&":$d$"&MAX(305,ROW(INDIRECT(H5))+1)),0)+ROW(INDIRECT(H5)),COLUMN($E5),4),"")
The reason I modify the subsequent columns is to change the range in which the formula is looking for its value to start at the next row after the previously found value. For example, with the data above, the formula in H5 would look for "2QB" in D5:D*n*, and return the first row it finds and attach it to column E, which would be E5.
The formula in I5 would then look for "2QB" starting in D*6* instead of D5, a row after the row referenced in H5's result.
Hopefully that made sense.
So what I end up with in my hidden worksheet is this:
G | H | I | J | K
-----------------------------
5 | QB | E5 | E7 | | |
6 | RB | E6 | | | |
7 | WR | | | | | . . .
Then, on my front page worksheet, I simply get the values (the bye) referenced by the cells in H5:*n*7 using:
=IFERROR(INDIRECT(lookups!H5),"")
...which gives me my final result:
G | H | I | J | K
-----------------------------
5 | QB | 8 | 11 | | |
6 | RB | 5 | | | |
7 | WR | | | | | . . .
Like I said, it's totally convoluted, but it works, and I can always refine it later if I figure out how. :) Thanks to you who took a swing at this seemingly complex problem for me! I'm sure your answers work beautifully as well.