If Then Count calculation on Questionnaire

GMC The Macro Man

Board Regular
Joined
Mar 23, 2023
Messages
104
Office Version
  1. 2021
Platform
  1. Windows
Good morning everyone
I'm trying to create a formula which looks at a cell and based on that criteria, goes to the data table and counts the number of entries and returns a % of correct answers. I believe it could be an IF, THEN, COUNT sort of thing but I don't know how to write it so I hope someone can help.
The attached file has 3 sheets.
Pupil List = has the user details
Questions = A list of questions & answers from pupils. These are imported from MS Forms questionnaires and these are done weekly so a pupil could have multiple dates
Results = The pupil sits a 1 to 1 verbal test and the score entered in Col D and Date in Col E. If they PASS they sit an test in MS FORMS and the data is captured in Questions sheet.

In RESULTS sheet Col H, I want to return the % score by counting the number of questions / the number correct = % for that date criteria

For Example
Robert sits the test in MS Forms on 8th Aug which has 5 questions and he gets 3 correct so 60% ( so the criteria is Robert, 8th Aug, Count questions divided by correct answers = %)

I hope I have explained this correctly
Questionairre.xlsx
ABCDEFGHIJK
1Pupil NameClassTeachers NameVoice Test ScoreAssessment DateVoice Test ResultPupil NameMS FORM Assessment Score %Pass Mark
2RobertS3Mr Brown7001/08/2023Failed 75
3DivyaS4Mrs Green8204/08/2023PassedDivya
4RobertS3Mr Brown9108/08/2023PassedRobert
5DivyaS4Mrs Green7911/08/2023PassedDivya
6RobertS3Mr Brown8215/08/2023PassedRobert
7  
8
9
10
11
12Name is entered manually from drop down listReturns the CLASS & TEACHERS name based on Column AManual entry - If score is 75 or above then they sit the MS FORM Test on the Assessment dateOutput based on Value of Column DIF PASSED enter Pupils Name - IF not PASSED then STOPIF PASSED - Goto Questions Sheet, MATCH Pupil Name & Assessment Date - COUNT number of questions and correct answers and return %Pass Mark
Results
Cell Formulas
RangeFormula
B2B2=XLOOKUP($A2,Pupil_List[Pupil Name],Pupil_List[Class],"")
C2:C5C2=XLOOKUP($A2,Pupil_List[Pupil Name],Pupil_List[Teacher],"",0)
B3:B5B3=XLOOKUP($A3,Pupil_List[Pupil Name],Pupil_List[Class]," ",0)
B6:B7B6=XLOOKUP($A6,DataTable[Pupil Name],DataTable[Class],"",0)
C6:C7C6=XLOOKUP($A6,DataTable[Pupil Name],DataTable[Teachers Name],"",0)
F2:F6F2=IF(D2<$K$2,"Failed","Passed")
G2:G6G2=IF($F2="Failed","",$A2)
Cells with Data Validation
CellAllowCriteria
A2:A6List='Pupil List'!$A$2:$A$5


Questionairre.xlsx
ABCDEF
1Pupil NameClassTeachers NameQuestionRight / WrongAssesment Date
2DivyaS4Mrs Green1. What sort of creature is a dingo?104/08/2023
3DivyaS4Mrs Green2. In which country is the Taj Mahal?104/08/2023
4DivyaS4Mrs Green3. Who was the first man to walk on the moon?004/08/2023
5DivyaS4Mrs Green4. What are the names of Harry Potter’s parents?104/08/2023
6DivyaS4Mrs Green5. What are the four oceans called?104/08/2023
7RobertS3Mr Brown1. Which language is spoken in Australia?108/08/2023
8RobertS3Mr Brown2. What is the name of the tree that produces acorns?108/08/2023
9RobertS3Mr Brown3. What is a baby kangaroo called?008/08/2023
10RobertS3Mr Brown4. How many sides does a hexagon have?108/08/2023
11RobertS3Mr Brown5. How many strings does a violin have?008/08/2023
12DivyaS4Mrs Green1. Which language is spoken in Australia?111/08/2023
13DivyaS4Mrs Green2. What is the name of the tree that produces acorns?111/08/2023
14DivyaS4Mrs Green3. What is a baby kangaroo called?111/08/2023
15DivyaS4Mrs Green4. How many sides does a hexagon have?111/08/2023
16DivyaS4Mrs Green5. How many strings does a violin have?111/08/2023
17RobertS3Mr Brown1. What sort of creature is a dingo?115/08/2023
18RobertS3Mr Brown2. In which country is the Taj Mahal?115/08/2023
19RobertS3Mr Brown3. Who was the first man to walk on the moon?015/08/2023
20RobertS3Mr Brown4. What are the names of Harry Potter’s parents?015/08/2023
21RobertS3Mr Brown5. What are the four oceans called?115/08/2023
Questions


Questionairre.xlsx
ABC
1Pupil NameClassTeacher
2DivyaS4Mrs Green
3PeterS4Mrs Green
4RobertS3Mr Brown
5SallyS3Mr Brown
Pupil List
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
How about
Excel Formula:
=LET(f,FILTER(Questions!$E$2:$E$100,(Questions!$A$2:$A$100=A2)*(Questions!$F$2:$F$100=E2)),ROWS(f)/SUM(f))
 
Upvote 1
Hi Fluff,
As always, thank you for taking the time to read my posts. On your solution I'm not seeing the correct output. (see image).
If you look at Divya for the 4th Aug - She answered 5 questions but only got 4 right so that should be 80% and not 125%. The others are the same except Divya on 11th Aug which is 5 out of 5 so 100% so thats correct.
Am i doing something wrong ?

1692359816189.png
 
Upvote 0
If you want 80% then it should be the "number correct/number of questions" rather than
number of questions / the number correct
So you would need
Excel Formula:
=LET(f,FILTER(Questions!$E$2:$E$100,(Questions!$A$2:$A$100=A2)*(Questions!$F$2:$F$100=E2)),SUM(f)/ROWS(f))
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 1
Sorry mate but I have just been asked a quick question on this.
The test is assigned and is normally completed on the same day, but say the pupil does not complete it same day but does on the next school day which is +1 or +3 (Fri - Mon).
Would there be a calc in the existing formula that you could add to say look at the assessment date and return the exact or date (+ within a couple of days.)

The pupils do these weekly so they are 7 days apart
 
Upvote 0
How about
Excel Formula:
=LET(f,FILTER(Questions!$E$2:$E$100,(Questions!$A$2:$A$100=A2)*(Questions!$F$2:$F$100>=E2)*(Questions!$F$2:$F$100<=E2+3)),SUM(f)/ROWS(f))
 
Upvote 1

Forum statistics

Threads
1,224,813
Messages
6,181,115
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top