Calculating average age of death by month/year in days

Pictus

New Member
Joined
Oct 8, 2018
Messages
4
Hi
I have a data set consisting of date of birth and date of death. I have calculated lifespan in days and have got mean and interquartile ranges from that. However, I would like to calculate lifespan based on months and separately years with the result being displayed in days - so I recalculate the mean etc. The premise is that the trend in the quartiles and mean values increase with lower accuracy levels.

I have double checked and the date columns are formatted as date. The equation below is the one for month, I have been trying to modify but haven't got it to work - any advise would be appreciated

=SUM((MONTH(B2:B15)=12)*C2:C15)/SUM(IF(MONTH(B2:B15)=12,1))

where column B is DOB and C is age (lifespan)
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi, welcome to the forum!

I have been trying to modify but haven't got it to work

What does your formula return? an error? the wrong result?

Maybe you could post an example of what you have in the range B2:B15 and what result you would expect for that example?
 
Last edited:
Upvote 0
How about ...

=SUMPRODUCT((MONTH(B2:B15) = 12) * C2:C15) / SUMPRODUCT(--(MONTH(B2:B15) = 12))
 
Upvote 0
Worked a treat! Thank you!!

I used the above and just changed Month to Year but it came back with a #DIV/0! error I dragged the formula for complete date range (yrs) to ensure I was capturing yrs that definitely had multiple records rather than just one record in a year. What's the tweak?

=SUMPRODUCT((YEAR($D$2:$D$42) = 1991) *$G$2:$G$42) / SUMPRODUCT(--(YEAR($D$2:$D$42) = 1991))
 
Upvote 0
Yes - the range for DOB and lifespan values doesn't change hence the $ signs. I fixed them when I did the month calculations as it kept altering by one. I tried the formula without the $ and the same error persists. Ideas?
 
Upvote 0
Fixed it - there is no data for the yr 1991 in my dataset!!
Thanks to you both for you help ;)
 
Upvote 0

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top