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:
-
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%.
-
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 + ...
- 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:
- 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.
- 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