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

Hope for help with formula if

Hi, I hope maybe someone can help me with this formula if/then.

There are three fields in the database:
Birthday (date)
RIP (date of death)
Age (formula)

If RIP is empty, the person is still alive, in which case the current age should be calculated:

dateBetween(now(),prop(“Birthday”), “years”)

If RIP is not empty, the person is already deceased, in which case the age at the time of death should be calculated:

“dateBetween(prop(“RIP”),prop(“Birthday”), “years”)

Unfortunately, my self-built formula, which is supposed to combine both formulas, does not work:

if(emptyprop(“RIP”), dateBetween(now(),prop(“Birthday”), “years”), if(not emptyprop(“RIP”), dateBetween(prop(“RIP”),prop(“Birthday”), “years”)

What must the formula be called for the condition described above to work?

1 Answer

0vote

ShaneRobinson Points2610

No need for the nested "if". It's much more simple:

if(empty(prop("RIP")),dateBetween(now(),prop("Birthday"),"years"),dateBetween(prop("RIP"),prop("Birthday"),"years"))

And if you want to make it styled:

if(empty(prop("RIP")),format("Current age: " + dateBetween(now(),prop("Birthday"),"years")).style("blue"),format("Age at death: " + dateBetween(prop("RIP"),prop("Birthday"),"years")).style("red"))

1vote

coco7 commented

Thank you very much for your help! Now it works

1vote

ShaneRobinson commented

YAY! Glad to help.

0vote

coco7 commented

so happy to find help here from you. I'm enthusiastic about Notion, but still a newbie.

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