Search code examples
google-sheetssumgoogle-sheets-formulaarray-formulassumifs

Fill missing dates in Google Sheets


I have two columns:

Col A                    Col B
01.02.2020               17
03.11.2020               24
03.11.2020               12

As I stated in another question, I tried to sum Col B, based on the month in Col A. The solution was the following formula (without the sort):

=ARRAYFORMULA(
  SUMIF(
    MID(A:A, 4, 2),
    SORT(UNIQUE(MID(FILTER(A3:A, A3:A <> ""), 4, 2))),
    B:B
  )
)

Something I missed was the population of missing months. Therefore my question is: How can I populate the result table with the missing months and zeroes until values are entered? The desired output for the table above would be:e

Col A                    Col B               Col C
01.02.2020               17                  0
03.11.2020               24                  17
14.12.2020               100                 0
03.11.2020               12                  0
                                             0
                                             0
                                             0
                                             0
                                             0
                                             0
                                             36
                                             100

Solution

  • If just doing it for the current year, this should be enough

    =ArrayFormula(sumif(mid(A2:A,4,2),sequence(12),B2:B))
    

    enter image description here