Is there a way to create a single header row of 12 dynamic Year-Month columns
(formatted yyyy-mmm
) using Google Query
? These dates should change based on a Year selection in say, Cell C1
. e.g. C1 could have values like 2016,2017,2018,2019,2020.
Example with formulas e.g.
=arrayformula(EDATE(date(C1,1,1),SEQUENCE(1,12,)))
or
=Arrayformula(EOMONTH(date(C1,1,1),SEQUENCE(1,12,)))
i was able to formulate the following:
=ARRAYFORMULA(TRANSPOSE(QUERY(TRANSPOSE(QUERY(EDATE(date(C1,1,1),SEQUENCE(1,12,)))),"SELECT Col1 LABEL Col1 'DATES' FORMAT Col1 'yyyy-mmm'")))
anyone has a shorter way, do let me know.
Alternatively, a shorter version, suggested by Tom Sharpe:
=ArrayFormula(date(C1,sequence(1,12),1))