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

Conditional formula for days

I have a Notion question I can't find the answer to.

For example, my weekly goal for a habit is 3 days a week. But when I mark 3 out of 7 days as chechbox, it shows 43%. Actually, I would like it to show 100% since my goal is already 3 days.

It only shows the habit completed 7 days a week as 100%.

How can I do this, any ideas?

Screenshot : https://gcdnb.pbrd.co/images/N5wEsLDBwav0.png?o=1

The current formula is as follows,

round(100 * (toNumber(replace(prop("Mon"), "true", "1")) + toNumber(replace(prop("Tue"), "true", "1")) + toNumber(replace(prop("Wed"), "true", "1")) + toNumber(replace(prop("Fri"), "true", "1")) + toNumber(replace(prop("Sat"), "true", "1")) + toNumber(replace(prop("Sun"), "true", "1")) + toNumber(replace(prop("Tue"), "true", "1"))) / 7) / 100

1 Answer

1vote

Martin_SystemsHill Points3740

Hey,

here are two formulas that will give you the desired effect.

This first one allows the percentage to go over 100% all the way up to 233% when the full week is completed.

round(100 * (toNumber(replace(prop("Mon"), "true", "1")) + toNumber(replace(prop("Tue"), "true", "1")) + toNumber(replace(prop("Wed"), "true", "1")) + toNumber(replace(prop("Thu"), "true", "1")) + toNumber(replace(prop("Fri"), "true", "1")) + toNumber(replace(prop("Sat"), "true", "1")) + toNumber(replace(prop("Sun"), "true", "1"))) / 3) / 100

This second one goes only up to 100% even when you complete more than 3 days.

min(1, round(100 * (toNumber(replace(prop("Mon"), "true", "1")) + toNumber(replace(prop("Tue"), "true", "1")) + toNumber(replace(prop("Wed"), "true", "1")) + toNumber(replace(prop("Thu"), "true", "1")) + toNumber(replace(prop("Fri"), "true", "1")) + toNumber(replace(prop("Sat"), "true", "1")) + toNumber(replace(prop("Sun"), "true", "1"))) / 3) / 100)

I would also recommend replacing the number "3" (your weekly goal) in the formula with prop("Goal") and adding a property "Goal" to your database. This way you can have different goal for each habit if needed

The two formulas would look like this then:

1) Allows over 100%:

round(100 * (toNumber(replace(prop("Mon"), "true", "1")) + toNumber(replace(prop("Tue"), "true", "1")) + toNumber(replace(prop("Wed"), "true", "1")) + toNumber(replace(prop("Thu"), "true", "1")) + toNumber(replace(prop("Fri"), "true", "1")) + toNumber(replace(prop("Sat"), "true", "1")) + toNumber(replace(prop("Sun"), "true", "1"))) / prop("Goal")) / 100

2) Upto 100%:

min(1, round(100 * (toNumber(replace(prop("Mon"), "true", "1")) + toNumber(replace(prop("Tue"), "true", "1")) + toNumber(replace(prop("Wed"), "true", "1")) + toNumber(replace(prop("Thu"), "true", "1")) + toNumber(replace(prop("Fri"), "true", "1")) + toNumber(replace(prop("Sat"), "true", "1")) + toNumber(replace(prop("Sun"), "true", "1"))) / prop("Goal")) / 100)

0vote

azofeifa commented

Hi Martin,

Thank you for reply.

enter image description here

Did you look at the image? 'Goal' property is already there.

I need something like below but I couldn't achieve it exactly. I was able to fix them all to 3 with the formula you gave :) Even if Goal is 6 days, it shows 100% when chechbox above 3 is checked.

I think I need this,

If '1 day/week' is selected as Goal, when 1 checkbox is checked, the progress bar is 100%

If '2 days/week' is selected as Goal, when 2 checkboxes are checked, the progress bar is 100%

..
..
..

If '7 days/week' is selected as Goal, the progress bar is 100% when the 7 checkbox is checked.

1vote

Martin_SystemsHill commented

Hey,

sorry I totally missed you already had the Goal there.
BTW I was just going through your formula again and please be carful about the days of the week. You have "Tue" there twice and you are missing "Thu". I would recommend using my formula exactly instead of adjusting yours to make sure it works.

Anyways. Here are the formulas that are going to work for your exact case. I tested it in my database and it works.

What it does is that it takes the first character from the property "Goal", changes it into a number and applies it to the formula.

1) Can go over 100%

round(100 * (toNumber(replace(prop("Mon"), "true", "1")) + toNumber(replace(prop("Tue"), "true", "1")) + toNumber(replace(prop("Wed"), "true", "1")) + toNumber(replace(prop("Thu"), "true", "1")) + toNumber(replace(prop("Fri"), "true", "1")) + toNumber(replace(prop("Sat"), "true", "1")) + toNumber(replace(prop("Sun"), "true", "1"))) / toNumber(slice(prop("Goal"), 0, 1))) / 100

2) Upto 100%

min(1, round(100 * (toNumber(replace(prop("Mon"), "true", "1")) + toNumber(replace(prop("Tue"), "true", "1")) + toNumber(replace(prop("Wed"), "true", "1")) + toNumber(replace(prop("Thu"), "true", "1")) + toNumber(replace(prop("Fri"), "true", "1")) + toNumber(replace(prop("Sat"), "true", "1")) + toNumber(replace(prop("Sun"), "true", "1"))) / toNumber(slice(prop("Goal"), 0, 1))) / 100)

1vote

azofeifa commented

Worked! great, thank you Martin.

1vote

Martin_SystemsHill commented

Great. I am glad I could help.

Can you please mark the question as answered if possible?

Thanks.

Martin

0vote

azofeifa commented

Done!

Thank you Martin.

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