将每日范围汇总为每周范围

时间:2015-06-15 14:07:20

标签: excel

我在A栏中有一个日常日期的表,在B栏中有一个股息支付。这看起来像是:

6/1/2015     0.05
5/31/2015
5/30/2015
5/29/2015
5/28/2015
5/27/2015
5/26/2015
5/25/2015
5/24/2015
5/23/2015   0.03
5/22/2015
5/21/2015
5/20/2015
5/19/2015
5/18/2015   0.01
5/17/2015
5/16/2015
5/15/2015
5/14/2015
5/13/2015
5/12/2015
5/11/2015
5/10/2015
5/9/2015
5/8/2015
5/7/2015
5/6/2015
5/5/2015
5/4/2015
5/3/2015
5/2/2015
5/1/2015
4/30/2015  0.02
4/29/2015
4/28/2015
4/27/2015
4/26/2015
4/25/2015
4/24/2015
4/23/2015
4/22/2015
4/21/2015

我想将红利总结为每周时间表,如下表所示:

6/1/2015     0.05 (= sum of entries in daily table between 6/1 and 5/26)
5/25/2015    0.04 (= sum of entries in daily table between 5/25 and 5/19)
5/18/2015    0.01 (= sum of entries in daily table between 5/18 and 5/12)
5/11/2015         (= sum of entries in daily table between 5/11 and 5/5)
5/4/2015     0.01 (= sum of entries in daily table between 5/4 and 4/28)
4/27/2015         (= sum of entries in daily table between 4/27 and 4/21)
4/20/2015         (= sum of entries in daily table between 4/20 and 4/14)

基本上,如果股息位于每周范围内的两个日期之间,则应将其汇总到B列中的相应单元格中。

有谁知道如何解决这个问题?非常感谢!

2 个答案:

答案 0 :(得分:3)

我的第一个想法是制作一个数据透视表,然后按天分组。来自网站http://www.contextures.com/xlPivot07.html

按周分组日期

按周划分日期字段中的项目

- 右键单击​​数据透视表中的其中一个日期 - 在弹出菜单中,单击“组” - 在“分组”对话框中,从“'”中选择“天”。名单。
- 对于'天数',选择7
- 周范围由'开始于'中的日期决定。框,所以必要时调整它。

答案 1 :(得分:1)

Use the Weeknum formula to create a third column in your list of dividends per date, so that for each line you have its week number in addition to date. Then on separate tab, you use sumif.

The following named ranges are assumed for convenience. Dividends tab: DividendDate, DividendPaid, DividendWeek Weekly dividends tab WeekNum, TotalDividendWeeløy In DividendWeek you enter the following formula (assume entered in C2, using row 1 for headings) =WEEKNUM(A2) and copy down. If going for over a year, you also need to add a year column.

Then if only doing this for 1 year, you add all week numbers required to Weeknum in weekly dividends tab, and the following formulate to TotalDividendWeekly cells, again assuming you start in row 2 due to headings being in row 1.

=SUMIF(DividendWeek;A2;DividendPaid)

No need for array formula.

NOTE! I use ; as formula separator. Might need to change to , if your language uses that.

EDIT: If you need years, and you probably do now I think of it, you have to add a Year column in the Dividends tab, using the =YEAR(A2) formulate to fill them, and change the SUMIF to a SUMIFS like this:

=SUMIFS(Dvidends;DividendWeek;A2;DividendYear;B2)

This assumes you have created a new column in the Weekly dividends tab in column B, so that the sumif formula is now in column C, and filled it with the correct years, and also created the new named range DividendYear in the Dividends tab.

For fun or if that is nice-to-have for you, you can also create a third tab summing the dividends for the years also, following the same principles as above.

If you want to use a Pivot, you can add the year and date columns as I suggested, create a pivot and then use those new columns to filter on. Good thing about pivot is that it is easy to maniplulate to show what you want. Bad thing is that it is static, so you need to update it to show new numbers. My version you can just scroll to the desired week, and it will always show you the correct values.