I am using Excel 2019
I have a large sheet of data containing dates.
On another sheet I wish to find the earliest date for each year, which I do using the following formula:
=AGGREGATE(15,6,Records!$F$2:$F$40000/((YEAR(Records!$F$2:$F$40000)=2005)*(Records!$I$2:$K$40000>0)),1) This example for the year 2005
I then wish to use the dates returned to find the average of these dates, but only the day and month, I want the average for all the years and just the last 10 years, I use the following formulas:
=SUMPRODUCT(DATE(0,MONTH(Mydates),DAY(Mydates)))/COUNT(Mydates) This for all years
=SUMPRODUCT(DATE(0,MONTH(Mydates),DAY(Mydates))*(Mydates>DATE(YEAR(TODAY())-11,12,31))/SUMPRODUCT(--(Mydates>DATE(YEAR(TODAY())-11,12,31)))) This for the last 10 years, “Mydates” is a named range of cells.
All formulas work ok if there is a full set of data.
But, the first formula returns a #NUM! error if there is no data for one of the years. This error then causes a #NUM! error in the second two formulas. I have tried adding IFERROR to the first formula to return a blank cell, but this then causes a #VALUE! error in the second two formulas.
Can anyone offer a solution ?
I have a large sheet of data containing dates.
On another sheet I wish to find the earliest date for each year, which I do using the following formula:
=AGGREGATE(15,6,Records!$F$2:$F$40000/((YEAR(Records!$F$2:$F$40000)=2005)*(Records!$I$2:$K$40000>0)),1) This example for the year 2005
I then wish to use the dates returned to find the average of these dates, but only the day and month, I want the average for all the years and just the last 10 years, I use the following formulas:
=SUMPRODUCT(DATE(0,MONTH(Mydates),DAY(Mydates)))/COUNT(Mydates) This for all years
=SUMPRODUCT(DATE(0,MONTH(Mydates),DAY(Mydates))*(Mydates>DATE(YEAR(TODAY())-11,12,31))/SUMPRODUCT(--(Mydates>DATE(YEAR(TODAY())-11,12,31)))) This for the last 10 years, “Mydates” is a named range of cells.
All formulas work ok if there is a full set of data.
But, the first formula returns a #NUM! error if there is no data for one of the years. This error then causes a #NUM! error in the second two formulas. I have tried adding IFERROR to the first formula to return a blank cell, but this then causes a #VALUE! error in the second two formulas.
Can anyone offer a solution ?