=IFERROR(IF(SUMPRODUCT((MONTH($R$22:$R$27)=MONTH(O4))*(SOURCE($Q$22:$Q$27)<>"")*(SUBTOTAL(103;OFFSET($R$22;ROW($R$22:$R$27)-MIN(ROW($R$22:$R$27));0))))=0;"";SUMPRODUCT((MONTH($R$22:$R$27)=MONTH(O4))*(SOURCE($Q$22:$Q$27)<>"")*(SUBTOTAL(103;OFFSET($R$22;ROW($R$22:$R$27)-MIN(ROW($R$22:$R$27));0)))));"")
This formula is a nested IFERROR, SUMPRODUCT, and SUBTOTAL function that returns the sum of the number of cells in the range SOURCE[BATCH] where the value in the column DATE is in the same month as the current month and the value in the cell is not empty.
If there are no such cells, it returns an empty string.
Here’s how it works:
SUMPRODUCT(array1, [array2], [array3], ...)
It will sum the number of times a month appears.
At our table:
Arrived types (sumproduct) |
---|
0 |
0 |
0 |
0 |
3 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
MONTH(serial_number)
Determines the number of the month of the cell.
At our table:
MONTH($R$22:$R$27) |
---|
6 |
6 |
6 |
6 |
6 |
6 |
At our table:
MONTH(O4) MONTH(O5) ... MONTH(O14) MONTH(O15)
1 2 ... 11 12
SUBTOTAL(function_num,ref1,[ref2],...)
Gives us a subtotal of a list. Applying "103" counts cells not empty in a list.
At our table:
DATE |
---|
1 |
1 |
1 |
1 |
0 |
0 |
OFFSET(reference, rows, cols, [height], [width])
Determines from which cell should the the subtotal count.
At our table:
Arrived Types (OFFSET) |
---|
#VALUE! |
#VALUE! |
#VALUE! |
#VALUE! |
#VALUE! |
#VALUE! |
ROW([reference])
Shows us the number of the row.
At our table:
Destiny 2 |
---|
22 |
23 |
24 |
25 |
26 |
27 |
MIN(number1, [number2], ...)
The lowest row.
At our table:
Destiny 2 |
---|
2 |