英文:
How to Average by day of week in Google Sheets?
问题
给定一个日期和值的表格。
如何按星期几平均?
我发现使用 AVERAGEIF 平均和 TEXT(E4, "dddd") 转换为星期几。
但如何结合这两个函数?
| 日期 | 数值 |
|---|---|
| 1/1/2001 | 1 |
| 1/2/2001 | 2 |
| 1/3/2001 | 3 |
| 1/4/2001 | 3 |
| 1/5/2001 | 6 |
| 1/6/2001 | 3 |
| 星期几 | 平均 |
|---|---|
| 星期日 | |
| 星期一 | |
| 星期二 | |
| 星期三 | |
| 星期四 | |
| 星期五 | |
| 星期六 |
英文:
Given a table of dates and values.
How to average by day of week?
I found AVERAGEIF to average and TEXT(E4, "dddd") to convert to day of week.
But how to combine those two functions?
| Date | Value |
|---|---|
| 1/1/2001 | 1 |
| 1/2/2001 | 2 |
| 1/3/2001 | 3 |
| 1/4/2001 | 3 |
| 1/5/2001 | 6 |
| 1/6/2001 | 3 |
| Day of Week | Average |
|---|---|
| Sunday | |
| Monday | |
| Tuesday | |
| Wednesday | |
| Thursday | |
| Friday | |
| Saturday |
答案1
得分: 3
使用QUERY()函数。尝试-
=QUERY({INDEX(TEXT(A1:A15,"dddd")),B1:B15},
"select Col1, avg(Col2) group by Col1 label Col1 'Day', avg(Col2) 'Average'")
要使其动态,请使用-
=QUERY({INDEX(TEXT(TOCOL(A1:A,1),"dddd")),TOCOL(B1:B,1)},
"select Col1, avg(Col2) group by Col1 label Col1 'Day', avg(Col2) 'Average'")
英文:
Go with QUERY() function. Try-
=QUERY({INDEX(TEXT(A1:A15,"dddd")),B1:B15},
"select Col1, avg(Col2) group by Col1 label Col1 'Day', avg(Col2) 'Average'")
To make it dynamic, use-
=QUERY({INDEX(TEXT(TOCOL(A1:A,1),"dddd")),TOCOL(B1:B,1)},
"select Col1, avg(Col2) group by Col1 label Col1 'Day', avg(Col2) 'Average'")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。




评论