I am experimenting with Named Functions in Google Sheets and trying to make a function to take start and end date arguments to look between within a custom formula. I cannot figure out how to put the dates in a preset comparison and work properly. (i.e. ">=start_date"
) will not accept the start_date
as an argument of the named function.If the start_date
variable is outside the parentheses, a formula parse error occurs.
I want to be able to input a date (i.e."1/1/1969"
) into my function and have the ">="
to be automatic.
For a simpler experiment I want to have MYFUNC
perform a SUMIF
after checking if a given value is ">="
:
Named Function syntax:
MYFUNC(sum_range,criteria)
Function definition:
=SUMIF(sum_range,">=criteria")
Example:
=MYFUNC(A1:A69,2)
My goal is that this example would sum the range A1:A69 if it was greater than or equal to two.
Named function syntax:
=MYFUNC(sum_range,date_range,start_date,end_date,criteria_range,criteria,placeholder)
Formula definition of my named function:
=IF(SUMIFS(sum_range,date_range,">=start_date",date_range,"<=end_date",criteria_range,criteria)=0,placeholder, SUMIFS(sum_range,date_range,">=start_date",date_range,"<=end_date",criteria_range,criteria))
I attempted populating the MYFUNC start_date
and end_date
as "1/1/1969"
with and without quotes. This does not populate the function with a date and results in zero value while if I use the formula definition in a cell, it functions and sums the values properly.