Basic Formula
Uses the SUM function on an array returned by FILTER. Then IFERROR is added to handle errors generated by FILTER when no dates match.
=IFERROR(SUM(FILTER(
cass!F:F, MONTH(cass!E:E)=3)), 0)
IFERROR(value, [value_if_error])
SUM(value1, [value2, …])
FILTER(range, condition1, [condition2, …])
Advanced Formula
A single formula can be used to perform the same calculations on different sets of data. To do that, it is necessary to generalize (abstract) the formula by replacing specific values that will change with named variables (placeholders). This process creates a formula that can be placed in a LAMBDA function.
=BYCOL(B1:E1, LAMBDA(n, BYROW(A2:A13, LAMBDA(d,
IFERROR(SUM(FILTER(
INDIRECT(n & "!F:F"),
MONTH(INDIRECT(n & "!E:E"))=MONTH(d))),0)))))

Steps from Basic Formula to Advanced
01: INDIRECT References
A formula is needed to generate the two required range references, for example cass!E:E
and cass!F:F
.
Range references can be built from text strings using the INDIRECT function as shown below:
|
A |
B |
C |
D |
1 |
abby |
berlin |
cass |
dylan |
2 |
=INDIRECT(A1 & "!F:F")
=abby!F:F
|
=INDIRECT(B1 & "!F:F")
=berlin!F:F |
=INDIRECT(C1 & "!F:F") =cass!F:F |
=INDIRECT(D1 & "!F:F") =dylan!F:F |
3 |
=INDIRECT(A1 & "!E:E") =abby!E:E |
=INDIRECT(B1 & "!E:E") =berlin!E:E |
=INDIRECT(C1 & "!E:E") =cass!E:E |
=INDIRECT(D1 & "!E:E") =dylan!E:E |
The six different formulas in A2:D3
above can be reduced to just two by using n
to represent the sheet name cell reference:
INDIRECT(n & "!F:F")
~ 1st Range
INDIRECT(n & "!E:E")
~ 2nd Range
02: Lookup Month
The lookup month integer, for example 3
if the month is March, can be returned by applying the MONTH function to a date value as shown below:
|
A |
B |
1 |
Jan 2021 |
=MONTH(A1)
=1 |
2 |
Feb 2021 |
=MONTH(A2)
=2 |
3-11 |
'' '' |
'' '' |
12 |
Dec 2021 |
=MONTH(A12)
=12 |
Replacing the cell reference for the dates by d
enables generalizing the lookup month integer as MONTH(d)
03: Generalizing the Basic Formula
Now, the Basic Formula,
=IFERROR(SUM(FILTER(
cass!F:F,
MONTH(cass!E:E)=3)), 0)
can be generalized to:
IFERROR(SUM(FILTER(
INDIRECT(n & "!F:F"),
MONTH(INDIRECT(n & "!E:E"))=MONTH(d))), 0)
04: Passing in the Values
Now that the formula has been generalized the values for the sheet names n
and the lookup date d
need to be passed into the formula for it to work.
Two related functions, BYROW (row-by-row) and BYCOL (column-by-column), are used that enable passing a range (or array) into a LAMBDA function.
The LAMBDA function uses a variable to represent the current row or column in its formula. By already generalizing the formula with variables, all that remains is to pass in the ranges and name the variables correctly in the LAMBDA function.
i. Lookup Month
BYROW is used to pass the range of lookup dates A2:A13
into the LAMBDA which assigns them the variable name d
BYROW(A2:A13, LAMBDA(d,
IFERROR(SUM(FILTER(
INDIRECT(n & "!F:F"),
MONTH(INDIRECT(n & "!E:E"))=MONTH(d))),0)
ii. Sheet Name
BYCOL is used to pass the range of sheet names B1:E1
into the LAMBDA which assigns them the variable name n
The formula is now complete
=BYCOL(B1:E1, LAMBDA(n, BYROW(A2:A13, LAMBDA(d,
IFERROR(SUM(FILTER(
INDIRECT(n & "!F:F"),
MONTH(INDIRECT(n & "!E:E"))=MONTH(d))),0)))))
=SUMIFS(Sheet!F3:F10,Sheet!E3:E10,">="&H1,Sheet!E3:E10,"<="&H2)
whereH1
&H2
has date01/04/2021 & 30/04/2021
,,, and if you wanna single VALUE from all sheets then an ARRAY formula id required !!INDIRECT
Function to reference a list of sheets in aSUMPRODUCT
andSUMIFS
not currently possible in Google Sheets.