Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9699

Calculating monthly average from daily average (grouped by month)

$
0
0

I have a spreadsheet with three columns: one for dates, one for daily income and one for daily change rates.

enter image description here

I want to have a sum of all the daily income grouped by month as seen above. For that, on cell E2 I have the following formula:

=ArrayFormula({unique(text(A2:A,"MMMYY")), sumif(text(A2:A,"MMMYY"),unique(text(A2:A,"MMMYY")),B2:B)})

It works well. Now, I would like to calculate the monthly average from the daily average (grouped by month). This is what I tried:

=ArrayFormula({unique(text(A2:A,""MMMYY"")), sumif(text(A2:A,""MMMYY""), unique(text(A2:A,""MMMYY"")),B2:B), AVERAGEif(text(A2:A,""MMMYY""), unique(text(A2:A,""MMMYY"")),C2:C)})

It doesn't work, it gives out the following:

ErrorFunction ARRAY_ROW parameter 3 has mismatched row size. Expected: 4. Actual: 1.

Edit: In the end, I found a way to make it work using query:

=query({ArrayFormula(EOMONTH(A2:A82,0)),B2:B82,C2:C82},"Select Col1, Sum(Col2),avg(Col2) group by Col1 format Col1'MMM-YY'")

Any ideas how to solve this without query?

Thanks!


Viewing all articles
Browse latest Browse all 9699

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>