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).
Related
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.
To identify duplicates in a large list of personal records, I'm replacing all names with a CONCATENATE of Name and Date of Birth (DOB). Here is the sheet I'm referencing (DOBs!):
DOBs! -----------------------------------------
C D E F G I K
Name Years Start End # Yrs DOB NewNameDOB
Sally Adams 2014-2014 2014 2014 1 1968-1204 Sally Adams1968-1204
John Agnew 2014-2014 2014 2014 1 1979-0419 John Agnew1979-0419
Bob Anderson 2013-2014 2013 2014 2 1965-0402 Bob Anderson1965-0402
Antonio Andrews 2014-2014 2014 2014 1 1955-0716 Antonio Andrews1955-0716
Julie Assan 2012-2014 2012 2014 3 1978-0805 Julie Assan1978-0805
On the main sheet (Employees!), each person has a row of data for each active year. Work 14 years, you have 14 lines of data to track.
Employees! -----------------------------------------
C D **E** F G H I J...
Year Name NewNameDOB Dept
2013 Julie Assan Julie Assan1978-0805 East
1998 Mike Rogers Duplicate in Same Year Main
1999 Mike Rogers Duplicate in Same Year Main
2000 Mike Rogers Mike Rogers1969-0510 Main
2001 Mike Rogers Mike Rogers1969-0510 Main
As mentioned, I need to separate duplicate names from 10395 records (like Mike Rogers and Mike Rogers). Employees! column E will now identify the employees as Julie Assan1978-0805 and Julie Assan1980-0131 (for example).
Today we take my first step, using the years they worked in order to solve 99% of the duplicates. After this, only a few duplicate names will be left who worked at the same time as each other, which I'll have to handle manually.
If the Employees! sheet has a 2013 record for "Julie Assan," then the first step is to check DOBs to find any Julie Assans who worked in 2013. My new column E in Employees! will take the current 2013 record of Julie Assan, and find any matches in DOB! where C (name) matches Julie Assan, E <= 2013, and F >= 2013. Usually, there will be only one match, and it will tell me that is Julie Assan1978-0805. Sometimes, there will be two Mike Rogers who worked during the same year, and it should tell me "Duplicate in Same Year".
On the Employees! sheet column E, I've started with this...
=index(DOBs!$k$2:$k$10395,match($d3&$c3,DOBs!$c$2:$c$10395& ??? ,0)
Not sure where to go with this formula, whether that means adding "IFs" or something different.
edited to explain in great depth
=IF(COUNTIFS(DOBs!C$2:C$10395,Employees!D2,DOBs!E$2:E$10395,"<="&Employees!C2,DOBs!F$2:F$10395,">="&Employees!C2)>1,"Duplicate in Same Year",INDEX(DOBs!K$2:K$10395,MATCH(TRUE,IF(DOBs!C$2:C$10395=Employees!D2,IF(DOBs!E$2:E$10395<=Employees!C2,IF(DOBs!F$2:F$10395>=Employees!C2,TRUE))),0)))
Enter as an array formula by confirming with Ctrl+Shift+Enter, then autofill down. It first checks for duplicates using COUNTIFS, and returns "Duplicate in same year" if it is. If there are not duplicates, it uses INDEX/MATCH to find the NewNameDOB.
Is there a way to make this
---A---
John
John
Tim
steve
John
-------
into this:
-----A--------B------
John 1
John 1
Tim 2
Steve 3
John 1
---------------------
Have a large data file with duplicate names, and would like to number them in the way mentioned in order to use them in another way.
Please try:
=IF(COUNTIF(A$1:A2,A2)=1,MAX(B$1:B1)+1,VLOOKUP(A2,A$1:B1,2,0))
in B2 copied down, with labels or blanks in Row1.
Tried doing this a few ways and I think I'm just looking at this a little too complicated.
I have column a with several different names that repeat. I have column B with dollar amounts. I'm trying to get a formula that will add the totals amount for a specific person.
JOHN $17.23
JAMES $37.52
JOHN $14.23
JAMES $27.52
APRIL $32.00
APRIL $143.20
JOHN $90.27
JOHN $81.13
JOHN = Total for John
JAMES = Total for James
APRIL = Total for April
Thank you
Assuming this table
A B
1 Names Bill
2 John 10
3 Tom 20
4 John 4
5 Tom 3
To get the total for each name you can write
A B
7 Names Total
8 John =Sumif(A2:A5;A8;B2:B5)
9 Tom =Sumif(A2:A5;A9;B2:B5)
This will sum up each value for the given area.
Consider:
=SUMPRODUCT((A$1:A$8="John")*(B$1:B$8))
=SUMPRODUCT((A$1:A$8="James")*(B$1:B$8))
=SUMPRODUCT((A$1:A$8="April")*(B$1:B$8))
Striking my original response in favor of:
=SUMIF(B3:B10,"=JOHN",C3:C10) I tested that, and it works even better
I have got a sheet with 2 columns, column 1 has got names in it and Column 2 has got percentage where some of them are identical. Now, I want to list out all the names that has got maximum percentage. Could anyone suggest me a way to do this?
Thanks,
Prabhat
With data like:
James 85.00%
John 47.00%
Robert 86.00%
Michael 34.00%
William 77.00%
David 93.00%
Richard 11.00%
Charles 16.00%
Joseph 36.00%
Thomas 93.00%
Christopher 83.00%
Daniel 89.00%
Paul 31.00%
Mark 93.00%
Donald 38.00%
George 91.00%
Kenneth 84.00%
Steven 6.00%
Edward 87.00%
Brian 24.00%
Ronald 48.00%
Anthony 35.00%
in A1 thru B22 .....clearly David Thomas and Mark share the maximum.
Pick a cell, say E2 and enter the array formula:
=INDEX($A$1:$A$22,SMALL(IF($B$1:$B$22=MAX(B:B),ROW($B$1:$B$22)),ROW()-ROW($E$2)+1))
copy down until you see an error. You should see something like:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.