Home » excel » excel – How to calculate an average grade from mix of number grades and letter grades whose values are determined via lookup table

excel – How to calculate an average grade from mix of number grades and letter grades whose values are determined via lookup table

Posted by: admin May 14, 2020 Leave a comment

Questions:

Data Table

enter image description here

Lookup Table

enter image description here

I want to calculate the average grade score of each pupil using an array formula and without the use of helper columns. If all grade are numbers its simple enough to average those, but when letter grades are introduced into the mix I need to convert these to their number values using the lookup table and then average the whole row for each pupil.

So far I was able to take one row and convert all grades that are letters to their corresponding values using the formula below.

=TRANSPOSE(INDIRECT("N"&(MATCH(TRANSPOSE(B2:E2),Table2[Grade],0)+1)))

which returns:

={#N/A,#N/A,7,3}

I then thought, great I got numbers in place of the letter grades, lets just “average” this result like so:

=AVERAGE(TRANSPOSE(INDIRECT("N"&(MATCH(TRANSPOSE(B2:E2),Table2[Grade],0)+1))))

which gives #N/A, which I do not understand when the following is completely allowed:

=AVERAGE({1,2,3})
How to&Answers:

One way to solve the case is to add all numerical grades to the 2 column Grade table you have in column M and N (technically it is not using helper columns?), then sort the Grade column in ascending order as shown below:

Grade Table

Then you can use the following array formula to find the average grade in cell F2:

=AVERAGE(LOOKUP(B2:E2,Tbl_Grade[Grade],Tbl_Grade[Attainment]))

Being an array formula, you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar otherwise it will not function correctly. Then you can simply drag the formula down to apply across.

Results

The logic is to use LOOKUP function to return the corresponding attainment for each given grade regardless if it is an actual number or a letter.

Let me know if you have any questions. Cheers 🙂

Answer:

Using VLOOKUPs seems like it would be much simpler:

=AVERAGE(B2,C2,VLOOKUP(D2,$M$2:$N$7,2,FALSE),VLOOKUP(E2,$M$2:$N$7,2,FALSE))

Answer:

If you can tolerate changing “A*” to say “A+” (or something else that doesn’t get interpreted as a wildcard) this may get you going:

=(SUM(B2:E2)+SUMPRODUCT(SUMIF(Table2[Grade],"="&B2:E2,Table2[Attainment])))/COUNTA(B2:E2)

The first SUM sums the numeric grades; the SUMPRODUCT(SUMIF(...)) sums the letter grades. Then divide the total by the number of grades (COUNTA).

Hope that helps