[英]Excel: max() of count() with column grouping in a pivot table
I have a pivot table fed from a MySQL view. 我有一个从MySQL视图获取的数据透视表。 Each returned row is basically an instantiation of "a person, with a role, at a venue, on a date".
返回的每一行基本上都是“某人在某个地点在某个日期上扮演一个角色”的实例。 The each cell then shows count of person (lets call it person_id).
然后,每个单元格都会显示人员计数(将其称为person_id)。
When you pivot this in excel, you get a nice table of the form: 当您在excel中进行旋转时,会得到一个漂亮的表格:
| Dates -->
--------------------------
Venue |
Role | -count of person-
This makes a lot of sense, and the end user likes this format BUT the requirement has changed to group the columns (date) into a week. 这很有道理,最终用户喜欢这种格式,但要求已更改为将列(日期)分组为一周。
When you group them in the normal way, this count is then applied in columns as well. 当您以常规方式将它们分组时,此计数也将应用到列中。 This is, of course, logical behaviour, but what I actually want is
max()
of the original count()
. 当然,这是逻辑行为,但是我真正想要的是原始
count()
max()
count()
。
So the question: Does anyone know how to have cells count()
, but the grouping perform a max()
? 那么问题来了:有人知道如何让单元格
count()
,但是分组执行max()
吗?
To illustrate this, imagine the columns for a week. 为了说明这一点,请想象一下一个星期的列。 Then imaging the
max()
grouped as a week, giving: 然后将
max()
成像为一个星期,给出:
Old: 旧:
| M | T | W | T | F | S | S ||
--------------------------------------- .... for several weeks
Venue X |
Role Y| 1 | 1 | 2 | 1 | 2 | 3 | 1 ||
New (grouped by week) 新增(按周分组)
| Week 1 | ...
---------------------------
Venue X |
Role Y| 3 | ...
I'm not on my pc, but the steps below should be broadly correct: 我不在我的电脑上,但以下步骤应大致正确:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.