如果另一列中的前一行相同,则累积总和
我正在尝试做一些在 Excel 中简单的事情,但我需要将其添加到我的查询中。如果名称列等于前一行,我试图在一列中的新时间值列中创建累积和。以下前后示例
数据输入表
ID | 时间 |
---|---|
A | 2 |
B | 3 |
C | 1 |
D | 0.5 |
E | 1 |
E | 3 |
E | 5 |
F | 2 |
G | 3 |
G | 4 |
H | 1 |
查询后表
ID | 时间 | 启动前 |
---|---|---|
A | 2 | 0 |
B | 3 | 0 |
C | 1 | 0 |
D | 0.5 | 0 |
E | 1 | 0 |
E | 3 | 1 |
E | 5 | 4 |
F | 2 | 0 |
G | 3 | 0 |
G | 4 | 3 |
H | 1 | 0 |
基本上,如果列 ID 等于其上方的行,则将时间与自身上方的 BeforeStart 行相加,如果不相等,则为 0。
I'm trying to do something that is simple in excel but I need it to be added in my query. I am trying to create a cumulative sum in a new column of time values in one column if a name column equals a previous row. Example of before and after below
Data Input Table
ID | Time |
---|---|
A | 2 |
B | 3 |
C | 1 |
D | 0.5 |
E | 1 |
E | 3 |
E | 5 |
F | 2 |
G | 3 |
G | 4 |
H | 1 |
Table After Query
ID | Time | BeforeStart |
---|---|---|
A | 2 | 0 |
B | 3 | 0 |
C | 1 | 0 |
D | 0.5 | 0 |
E | 1 | 0 |
E | 3 | 1 |
E | 5 | 4 |
F | 2 | 0 |
G | 3 | 0 |
G | 4 | 3 |
H | 1 | 0 |
Basically if column ID equals the row above itself then sum the time and BeforeStart rows above itself, if it doesn't then it is 0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 powerquery 中,尝试将 Table2 替换为源数据表的名称
In powerquery, try below and replace Table2 with the name of your source data table
试试这个功能:
Try this function: