How to turn letter grades into numbers so I can preform mathematical functions

How to turn letter grades into numbers

Can I please get help on turning letter grades into numbers so I can preform mathematical functions. In my daily journal I rank my day with a letter grade from A+ to D-, but I want to find the average of all my days. Since the letter grades aren’t numbers I can’t use mathematical function with them like sum(),min(), max(), or avg().

So is there a way I can assign my letter grades a specific number like
A+ = 1, A = 2, A- = 3… D- = 11. Then I can use the average function because they will be numbers. Also once I get my average number how can I turn it back in a Letter grade?

Things I have tried

I have managed to sort my day rankings with letter grades from best to worst using the code in the image perhaps that could help find an answer.

```dataview
TABLE date, rank, rankPoints, mood, quality, productivity
FROM "Daily Journal"
FLATTEN object("A+", 1, "A", 2, "A-", 3, "B+", 4, "B", 5, "C+", 6, "C", 7, "C-", 8, "D+", 9, "D", 10, "D-", 11, "F", 12)[rank] AS rankPoints
SORT rankPoints
```

Dataview docs: object constructor

1 Like

You are a life saver, I was going insane trying to find the solution. Your code works perfectly and you have all my gratitude, seriously thank you so much.

1 Like