13 Replies Latest reply on Feb 11, 2019 12:38 PM by lu.gan.2

# Age calculation

Hi everyone!

Dose anybody know how to calculate age?

I have everybody's birthdate(year), than how can I calculate their average age? (e.g., a person was born in 1936, then how old is he in 2018?)

(I guess I need to create a new calculated field, but how to write the content...?)

Thank you so much! • ###### 1. Re: Age calculation

Hi,

You can write it as

DATEDIFF('year', [Year of Birth], YEAR(Today()))

• ###### 3. Re: Age calculation

My apologies, I got confused

You can rewrite it as

DATEDIFF('year', [Birth Date],Today()) -- this gives you years

Also otherway to write it is YEAR(Today())-YEAR([Birth Date])

If you want to also calculate months, replace 'year' with 'month' in datediff calculation.

1 of 1 people found this helpful
• ###### 4. Re: Age calculation

Thank you Maneesh! I tried this time and without any error but the results are kind of weird..

555 years old...? • ###### 5. Re: Age calculation

It is probably summing up the age. Right click on your age field and select convert to dimension. Tableau moves the field to the dimensions pane and from there drag the field to the rows. It should fix it.

1 of 1 people found this helpful
• ###### 6. Re: Age calculation

Got it!!!

Thanks a lot!

• ###### 7. Re: Age calculation

One quick question.

How can I make those ages changes with a certain year ? For example, when I adjust the Year filter, the age will change along with it.(The end date is not Today but the year that I choose.)

Thanks!!! • ###### 8. Re: Age calculation

Is that year filter a parameter?

If so, you can write your calculated field as

[YEAR Parameter]-YEAR([Birth Date])

• ###### 10. Re: Age calculation

Then it would be

INT([Year]) - YEAR([Birth Date])

1 of 1 people found this helpful
• ###### 11. Re: Age calculation

Life saver!!!

Any suggestion on learning Tableau? (Cannot find a good tutorial online~~~)

• ###### 12. Re: Age calculation

Look no other than free Tableau learning videos Learning | Tableau Software. I found them very helpful.

• ###### 13. Re: Age calculation

Got you~!! Many thanks~!