Notion Answers

Help between Notion users


Register & Ask

It's free & easy

Get answers

Answers, votes & comments

Vote and select answers

Receive points, vote and give the solution

Question

1vote

Turning habit percentages into grades

I'm trying to create a yearly grade based on habit percentage and so far I have the percentage showing and I have Grade F showing but this grade doesn't change when I check the habits.

Habit 1 is a checkbox, Habit 1a is unaryPlus(prop("Habit 1")) which comes out as a decimal number.

Total Habit 1 is "Habit 1:

" + format(round(100 * prop("Habit 1"))) + "%" + " , " + if(prop("Habit 1a") >= 100, "A+", if(prop("Habit 1a") >= 89, "A", if(prop("Habit 1a") >= 84, "A-", if(prop("Habit 1a") >= 79, "B+", if(prop("Habit 1a") >= 76, "B", if(prop("Habit 1a") >= 72, "B-", if(prop("Habit 1a") >= 69, "C+", if(prop("Habit 1a") >= 64, "C", if(prop("Habit 1a") >= 59, "C-", if(prop("Habit 1a") >= 54, "D+", if(prop("Habit 1a") >= 52, "D", if(prop("Habit 1a") >= 48, "D-", if(prop("Habit 1a") >= 30, "E", "F"))))))))))))) 

This is currently showing Habit 1: 38% , F

If I change "Habit 1a" to "Habit 1" in the formula, I still get the same result.

How do I get the grade to change based on the percentage number? Thank you!

2 Answers

2votes

stardive Points280

UPDATE: I solved it and for anyone that's curious, I changed Habit 1a to unaryPlus(prop("Habit 1")) * 100

I also created a way to have habits as the different pages (rows), with the days as the columns and still show the percentages and grades. For anyone that's curious-

  • Create your habits as different pages/rows
  • Create checkbox columns for all the days in the week
  • Create a formula property for total no.
floor(100 * (toNumber(prop("Mon")) + toNumber(prop("Tues")) + toNumber(prop("Wed")) + toNumber(prop("Thurs")) + toNumber(prop("Fri")) + toNumber(prop("Sat")) + toNumber(prop("Sun"))) / 7)
  • Create a formula property for total progress and grade - "Total:
" + format(round(prop("Total No."))) + "%" + " , " + if(prop("Total No.") >= 100, "A+", if(prop("Total No.") >= 89, "A", if(prop("Total No.") >= 84, "A-", if(prop("Total No.") >= 79, "B+", if(prop("Total No.") >= 76, "B", if(prop("Total No.") >= 72, "B-", if(prop("Total No.") >= 69, "C+", if(prop("Total No.") >= 64, "C", if(prop("Total No.") >= 59, "C-", if(prop("Total No.") >= 54, "D+", if(prop("Total No.") >= 52, "D", if(prop("Total No.") >= 48, "D-", if(prop("Total No.") >= 30, "E", "F")))))))))))))

2votes

Martin_SystemsHill commented

Nice! Happy you solved it yourself. :)

2votes

Hi,

so based on the details you provided, the issue seems to be with your thresholds in the nested if statements. You mentioned that Habit 1a is the result of unaryPlus(prop("Habit 1")), which converts the checkbox into a decimal: 1 (for checked) or 0 (for unchecked). Thus, Habit 1a will always be 0 or 1, which means all the thresholds you've set (like >= 100, >= 89, etc.) will never be met, and the result will always be "F".

The primary issue is the source of your percentage. You seem to want to calculate the grade based on a percentage, but a single checkbox does not give you a percentage unless it's being compared against a set number of tasks or habits.

You can fix it this way if you absolutely have to keep it in one formula:

  1. Clarify Your Habits Calculation:

    • If you're basing the grade on multiple habits, you need to decide how many habits (or tasks) you have in total. Let's say you have 10 habits you want to track.
    • Every time you check a box, your Habit 1a should increase by 10 (since 1 out of 10 is 10%).
    • If you have 3 out of 10 habits checked, Habit 1a should be 30, representing 30%.
  2. Update Your Habit 1a Calculation:

    • If you're working with multiple habits, you'll need a way to sum them. For simplicity's sake, let's assume you have Habit 2, Habit 3, etc.:
      • Habit 1a = unaryPlus(prop("Habit 1")) * 10 + unaryPlus(prop("Habit 2")) * 10 + ...
  3. Update Your Grade Calculation:
    • With the updated Habit 1a, your nested if statement should work correctly since Habit 1a will now reflect a value between 0 and 100, representing the percentage of habits you've checked off.

Although if not absolutely necessary I would highly recommend to separate the percentage and grade calculations.

I'd do something like this:

  1. The Percentage Calculation:

Let's assume you have 10 habits you want to track (Habit 1 through Habit 10). The percentage achieved from these habits can be calculated as:

Habit Percentage: (unaryPlus(prop("Habit 1")) + unaryPlus(prop("Habit 2")) + ... + unaryPlus(prop("Habit 10"))) * 10

This formula will give you a value between 0 and 100, representing the percentage of habits you've achieved.

  1. The Grade Calculation:

Now, using the Habit Percentage you've calculated, determine the grade in a separate property:

if(prop("Habit Percentage") >= 100, "A+", 
if(prop("Habit Percentage") >= 89, "A", 
if(prop("Habit Percentage") >= 84, "A-", 
if(prop("Habit Percentage") >= 79, "B+", 
if(prop("Habit Percentage") >= 76, "B", 
if(prop("Habit Percentage") >= 72, "B-", 
if(prop("Habit Percentage") >= 69, "C+", 
if(prop("Habit Percentage") >= 64, "C", 
if(prop("Habit Percentage") >= 59, "C-", 
if(prop("Habit Percentage") >= 54, "D+", 
if(prop("Habit Percentage") >= 52, "D", 
if(prop("Habit Percentage") >= 48, "D-", 
if(prop("Habit Percentage") >= 30, "E", 
"F")))))))))))))

Let me know if this worked for you.

Martin

0vote

stardive commented

Oh amazing, thank you for your help! That also looks like a much cleaner and better way to do it than what I've done!

Please log in or register to answer this question.

...

Welcome to Notion Answers, where you can ask questions and receive answers from other members of the community.

Please share to grow the Notion Community!

Connect