[英]Excel Grouping by week with specific hour as start and end
I am looking to use a pivot table to display a data set with dates. 我正在寻找使用数据透视表来显示带有日期的数据集。 I would like to group the data by week, which I have been able to do through the pivot table, however, I have not been successful in doing this with reference to a specific start and end hour every week, which is what I need. 我想按周对数据进行分组,这已经可以通过数据透视表完成,但是,我并没有成功地参考每周所需的特定开始和结束时间进行此操作。
For example, my data starts on Wednesday, the 9th of March with a data point at 15:43, then there are more data points every few minutes leading up to the current day. 例如,我的数据从3月9日(星期三)开始,数据点为15:43,那么直到今天为止,每隔几分钟就有更多数据点。 I would like to group this starting at 15:00 on Wednesday with each grouping running for one week, ending at 15:00 on the following Wednesday and continuing along this pattern up to the current day and into the future as the table is updated. 我想对这个分组进行分组,从星期三的15:00开始,每个分组运行一个星期,在下一个星期三的15:00结束,并按照这种模式一直进行到今天,直到表更新为止。
To illustrate this: Start of Grouping: Wednesday, 09/03/17 15:00, end of grouping/start of next group Wednesday, 16/03/17 15:00. 为了说明这一点:分组开始:09/03/17星期三15:00,分组结束/下一小组的开始16/03/17星期三15:00。
Does anyone know if this can be done with or without pivot tables in Excel? 有谁知道这是否可以在Excel中使用数据透视表来完成? Help would be much appreciated since there does not seem to be a lot of info for this particular issue with respect to the specific hourly start and end time of a weekly group. 非常感谢您的帮助,因为有关该特定问题的每周小组的特定每小时开始和结束时间似乎没有很多信息。
I am using Excel 2016 for Mac. 我正在使用Excel 2016 for Mac。
Yes, this can be done with PivotTables, using the Grouping function: 是的,可以使用分组功能通过数据透视表完成此操作:
...but unfortunately the result is sorted alphabetically, not by date order: ...但是不幸的是,结果是按字母顺序而不是按日期顺序排序的:
It should be possible to write some code to sort these in the proper order using a Custom Sort Order, if this is the approach you want to take. 如果您要采用这种方法,应该可以编写一些代码,以使用“自定义排序顺序”以正确的顺序对它们进行排序。 Otherwise, Chris' approach is a good one. 否则,克里斯的方法是一个很好的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.