I have a spreadsheet containing rating data for hundreds of leaders in our organization. Using VBA, I would like to find the average rating on each question for each leader. Example:
My data is is the following format
-Name Question Rating
-John Q1 4
-John Q1 2
-John Q2 3
-John Q2 2
-Heather Q1 5
-Heather Q1 3
-Heather Q2 3
-Heather Q2 1
I would like to get the below result based on this data.
John
Q1 Average 3
Q2 Average 2.5
Heather
Q1 Average 4
Q2 Average 2
Hopefully this is clear. I am somewhat new to VBA, so thanks for the help!
I second Lisa's suggestion of a PivotTable. There's no need for custom VBA code when Excel has out-of-the-box functionality to do what you want.
Related
Sorry if I have completely butchered the terminology in the title. Relatively new to Excel.
I have the following table.
Name
Score A
Score B
Score C
Bob
10
8
6
Sue
9
12
10
Joe
11
2
4
Susan
7
9
10
Tim
10
12
4
Ellie
9
8
7
What I am trying to achieve is that for each person, to return the score type for that person's best score. I'm referencing the person's name on another sheet.
For example. For Susan;
Their best score is 10 and that is under Score C.
So I want the final value in the Score Type column in my other sheet for Susan to be Score C
Like so
Name
Best Score
Score Type
Ellie
9
Score A
Bob
10
Score A
Susan
10
Score C
I know to get the index of each persons row by
=MATCH(A2,$A$2:$A, 0)
I can get the max value for that person via
{=MAX(IF($A$2:A = A2,($B$2:$D)))}
I'm just not sure how to use that information to return the column label corresponding to the person and their max score.
Any help would be greatly appreciated
I think it is pretty easier. Try-
=INDEX($B$1:$D$1,MATCH(MAX(B2:D2),B2:D2,0))
For dynamic spill array-
=BYROW(B2:D7,LAMBDA(x,FILTER(B1:D1,x=MAX(x))))
EDIT: Then try below formula-
=INDEX($B$1:$D$1,1,MAX(($A$2:$A$7=$I3)*($B$2:$D$7=$J3)*(COLUMN($B$2:$D$7)))-COLUMN($A$2))
For Larger Data you could use this one
The objective is to calculate the total allowance for the kids in my data set that are aged 12+. In this example using the data set below, the outcome should be 9 (5+2+2). Can someone please help me with a formula? Thanks!
ID Age Allowance
Fred 12 6
Fred 15 10
Fred 18 5
Joe 12 2
Sam 12 2
DJ 10 1
With Office 365 Excel:
=SUMPRODUCT(SUMIFS(C:C,A:A,A2:A7,B:B,">=12",B:B,MAXIFS(B:B,A:A,A2:A7))/COUNTIFS(A:A,A2:A7))
If one does not have Office 365 Excel then one can use a helper column and sum that.
In D2 Put:
=IF(AND(B2=AGGREGATE(14,7,$B$2:$B$7/($A$2:$A$7=A2),1),B2>=12),C2,"")
And copy down. Then sum at the bottom.
I need to create something that is used to track and report class ratings. The class evaluation form has eight questions and the ratings are from 1-4. We need to show the average rating for each question per class. It will be an ongoing list so needs to have functionality that allows users to continue to add new class ratings without re-formatting the spreadsheet.
Example, Class PD100 has a total of 5 for Q1. I need to show the average score of 1.6 for that question. Then the same for all the other questions grouped by Class.
Class # Q1 Q2 Q3 Q4
PD100 1 2 3 1
PD100 3 2 3 4
PD100 1 2 3 1
PD200 2 1 2 2
PD200 1 2 3 4
PD200 1 4 1 4
PD300 1 4 4 1
This is a bit unwieldy as the data is already laid out in a pivot, but the total average columns give you what you're looking for in creation of a pivot table.
if the data was laid out class question answer the pivot could be cleaner.
.
I got this kind of database :
NAME QUESTION ANSWERED
Brian Q1 Yes
Brian Q1 Incorrect
Brian Q1 No
Brian Q1 Yes
Brian Q2 Yes
Brian Q2 Yes
Brian Q2 Incorrect
John Q1 Yes
John Q1 Yes
John Q1 No
John Q1 Yes
John Q2 No
John Q2 Yes
John Q2 Incorrect
I want to do a cross table in Excel 2010 to calculate a percent of "Yes" answered for each question.
The result should be like this :
QUESTION
NAME Q1 Q2
Brian 50% 66%
John 75% 33%
I mean : Brian answered 4 times to question Q1. He answered 2 times "Yes", so the percentage of yes answered is 50% (2/4*100).
How can I do this in a cross table ? I put NAME on lines, QUESTION on column, and ANSWERED on values. Know if a add a filter on ANSWERED, the percentage calculate by Excel is only on filtered values, not on the total of question Q1.
Add a 4th column with the formula =IF(C2="Yes",1,0). Then put that in the "Values" section of the PivotTable, and calculate the Average (instead of the Sum which is the default).
I'm working on Excel with a lot of data and I'm having difficulty with knowing how to sort through it to get some important numbers. I have minimal Excel experience.
Right now I'm struggling with knowing how to get the average in the difference between two columns. The trick is that I have to get the average in difference when column A is less that column B and then, the same when it's more. And all that within a category.
So for example let's say I have 3 categories: Football, Soccer, and Basketball (these are just made up ones).
So in column A, I have: Soccer, Football, Basketball. Then, in column B and C, I have the scores for John and Adam for the last 3 months, respectively. Lastly, in column D, I have the differences between their scores.
So, for example:
Category John Adam Differences
Soccer 5 3 2
Soccer 6 2 4
Soccer 3 5 2
Soccer 4 0 4
I want to create a table for within each category I have a table like below:
NÂș of cases Avg. Difference between John and Adam
When John's score is >
When John's score is <
When they are equal
Is there some type of formula where I can say something like this:
If the category is Soccer (the category being in column A), take the difference between John's score (column B) and Adam's score (column C) when John's score is larger than Adam's score, then calculate the average of those differences? Then, I would use the same formula but tweak it when John's score is smaller.
Additionally, would there be a formula where I can also, calculate within the category Soccer, how many times John's score is bigger than Adam's?
My data is much larger and I can't do this manually.
A B C D
1 Sport John Adam Differences
2 Soccer 5 3 2
3 Soccer 6 2 4
4 Soccer 3 5 -2
5 Soccer 4 0 4
6 Basketball 20 15 5
7 Basketball 7 13 -6
8 Basketball 26 10 16
9 Basketball 8 11 -3
Type in D1:
=B1-C1
Drag the formula in Column D to all rows which there are values in columns A, B and C.
Create the PivotTable.
Drag Sport to "Row Label" field. Drag Differences to "Row Label" field under Sport.
Drag Differences to "Values" field as: Count of Differences (same way the previous question)
Drag Differences to "Values" field (below Count of Differences), and set the mathematical operation as "Average" of Differences (left-mouse click Differences, choose "Values fields settings" and select "Average").
Give a right-click mouse in cell A5 (see picture bellow) and select "Group" option.
Set "Starting at" = 0; "Ending at" = 1000; "By" = 1000 (as in the picture below). Click ok.
You will have in each Sport, the count (frequency) and average Differences values for two groups:
When the Difference B1-C1 is negative; and
When the Difference B1-C1 is zero or positive.
The average of Differences when the score is equal will be always zero.