3 Replies Latest reply on Nov 27, 2018 12:47 PM by Jeff Strauss

# Calculating Lifespan

I would like make a calculated field with the liefspan of people. So far I have only two dimensions in colums: birthyear and to. But sometimes in the "to" colum, there is a "0", because the person is still alive.

What abou this idea?

IF [To] = "0" THEN 2018 ELSE [To] - [Birthyear] END

• ###### 1. Re: Calculating Lifespan

Hi Zora,

Not sure how your data is structured (data types/values), but you're close I think?  Please see below and attached 2018.3 workbook.  Thx, Don

• ###### 2. Re: Calculating Lifespan

It should be this way: IF [To] = "0" THEN 2018 - INT([Birthyear]) ELSE INT([To]) - INT([Birthyear]) END

I am not sure what data type you are seeing for the "To" and "Birthyear". So, to avoid any issues, I have added an INT function around them.

• ###### 3. Re: Calculating Lifespan

Maybe something like this will work for you?  It outputs "Alive" if To = "0", otherwise, it does the calc of To - Birthyear and converts it to a string.

IIF([To}="0","Alive",str([To]-[Birthyear]))