Help between Notion users

It's free & easy

Receive points, vote and give the solution

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?

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 Aug 26

Thank you very much for your help! Now it works

1vote

0vote

### coco7 commented Aug 26

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