楼主: coral033
6749 1

[学习分享] 月度数据转换季度数据公式 [推广有奖]

  • 1关注
  • 17粉丝

VIP

古墓派预测分支

已卖:3260份资源

副教授

71%

还不是VIP/贵宾

-

威望
1
论坛币
114832 个
通用积分
157.6483
学术水平
58 点
热心指数
101 点
信用等级
49 点
经验
3219 点
帖子
522
精华
1
在线时间
695 小时
注册时间
2007-3-10
最后登录
2023-12-12

楼主
coral033 在职认证  发表于 2015-8-12 13:21:58 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Excel Formulas to Summarise Monthly Data into Quarters

来源: http://www.myonlinetraininghub.c ... -data-into-quarters





I had a question from Somnath this week asking what formula he could use to summarise his monthly data into quarters without having to edit the formula for each quarter.

Let’s imagine Somnath is selling ‘things’ and his data looks like this:

And in rows 16:19 he wants to summarise it into quarters by entering a formula in cell B16 and then copying it to the remainder of the table without so much as an F2, or double click to edit any formulas.

Summarise Monthly Data into Quarters

We can achieve this with a dynamic range using the OFFSET function.

If you haven’t come across OFFSET before I recommend you read up on it here with my treasure map example before continuing on.

Ok, let’s take a closer look at the formula in B16:

=SUM(OFFSET(B$2,3*ROWS(B$2:B2)-3,,3))  [只要把这个公式拷贝到excel中即可,相应修改B2]

Remember, the OFFSET function returns a reference to a range that is a given number of rows and columns from a reference. The syntax is:

=OFFSET(reference,rows,cols,[height],[width])

I’ve crossed out the cols and width arguments as we don’t need them since our range is only 1 column wide.

In my formula the reference argument is the first cell in the table; B2.

The rows argument tells Excel the number of rows, up or down, that we need to move away from the reference to get to the first cell in our range.

Now remember we don’t want to edit this formula for each quarter so we’ve made it calculate the rows argument dynamically incorporating the ROWS function and the strategic use of absolute and relative references.

Now, the ROWS function simply returns the number of rows in a range. Since there is one row in the range B2:B2 our formula evaluates like this:

=SUM(OFFSET(B$2,3*1-3,,3)) which becomes:=SUM(OFFSET(B$2,0,,3))

In English the above OFFSET formula reads: starting in cell B2 move zero rows down (i.e. start in cell B2) and make the range 3 cells high, which is:

=SUM(B$2:B4)

Let’s look at Quarter 2’s formula in cell B17:

=SUM(OFFSET(B$2,3*ROWS(B$2:B3)-3,,3))

Notice how the ROWS formula reference is now B2:B3.

So, the ROWS formula evaluates to 2 since there’s 2 rows in the range B2:B3:

=SUM(OFFSET(B$2,3*2-3,,3)) which becomes:=SUM(OFFSET(B$2,3,,3))

In English the above OFFSET formula reads: starting in cell B2 move 3 rows down, that’s B5 and make the range 3 cells high. Which is:

=SUM(B5:B7)Horizontal Data

Got your months going across columns instead of down rows like the table below?

No problem, you can use this formula which uses the COLUMNS function instead of ROWS:

=SUM(OFFSET($L2,,3*COLUMNS($L$2:L2)-3,1,3))

The COLUMNS function returns the number of columns in a range.

Download the Excel workbook.

summarise_mths_into_qtrs.xlsx (27.3 KB)



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:季度数据 月度数据 数据转换 Dynamically References quarters entering question selling monthly

已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
客初 + 20 + 2 + 3 + 2 精彩帖子

总评分: 论坛币 + 20  学术水平 + 2  热心指数 + 3  信用等级 + 2   查看全部评分

Out of difficulties, makes miracles.

沙发
legolasorlando 发表于 2015-8-30 18:10:54
谢谢分享,学习了

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 00:21