Search code examples
arraysgoogle-sheetsaggregateflattengoogle-query-language

Google sheets group by date-column and aggregate (average) all other numeric ones


I'm a total beginner with doing data-analysis in google sheets. I have a sheet: (https://docs.google.com/spreadsheets/d/1WXTb14NU1IB5Dqgevrd4DaF1MoRkK1YQi58N9KRuTEA/edit?usp=sharing), that has a date column and some numeric columns.

I want to group by the date column and compute the average on the others. The sheet looks like this:

enter image description here

In R it could look like this:

df %>%
  group_by(date) %>%
  summarise(across(where(is.numeric),
                   ~mean(.x)))

Solution

  • try:

    =INDEX(QUERY(SPLIT(FLATTEN(A2:A&"×"&OFFSET(B2,,,9^9, 3)), "×"),
     "select Col1,avg(Col2) where Col2 is not null
      group by Col1 label avg(Col2)''"))
    

    enter image description here

    see: stackoverflow.com/q/65435313/5632629