有没有办法动态更改 MS Excel 中计算使用的范围?
我有一个像这样的数据集 -
slice | time_id | Weight |
---|---|---|
1 | 0 | 10 |
2 | 0 | 20 |
3 | 0 | 30 |
1 | 1 | 10 |
2 | 1 | 5 |
3 | 1 | 25 |
1 | 2 | 30 |
2 | 2 | 10 |
3 | 2 | 20 |
获得排名列的最佳方法是什么?计算与前一个 time_id 对应的切片的排名? 例如,同一个表的输出应如下所示 -
slice | time_id | Weight | Rank |
---|---|---|---|
1 | 0 | 10 | 0 |
2 | 0 | 20 | 0 |
3 | 0 | 30 | 0 |
1 | 1 | 10 | 3 |
2 | 1 | 5 | 2 |
3 | 1 | 25 | 1 |
1 | 2 | 30 | 2 |
2 | 10 | 2 | 3 |
3 | 2 | 20 | 1 |
我尝试了excel排名功能(必须手动设置排名范围在函数中,对每个 time_id 进行排名(切片,范围),但这是太多的手动工作,而且我有数百个切片和时间段。那么实现这一目标的最佳方法是什么?
我的目标是根据 time_id-1 期间的权重找到 time_id 的前 n 个切片
I have a dataset like this -
slice | time_id | weight |
---|---|---|
1 | 0 | 10 |
2 | 0 | 20 |
3 | 0 | 30 |
1 | 1 | 10 |
2 | 1 | 5 |
3 | 1 | 25 |
1 | 2 | 30 |
2 | 2 | 10 |
3 | 2 | 20 |
What will be the best method to get a rank column, which computes the rank for slices corresponding to the previous time_id?
For instance, the output for the same table should look something like this -
slice | time_id | weight | Rank |
---|---|---|---|
1 | 0 | 10 | 0 |
2 | 0 | 20 | 0 |
3 | 0 | 30 | 0 |
1 | 1 | 10 | 3 |
2 | 1 | 5 | 2 |
3 | 1 | 25 | 1 |
1 | 2 | 30 | 2 |
2 | 2 | 10 | 3 |
3 | 2 | 20 | 1 |
I tried the excel rank function (had to manually set the rank range in the function, rank(slice, range) for every time_id), but it is too much manual work and I have slices and time periods in the hundreds. So what will be the best way to achieve this?
My objective is to find the top n slices for a time_id, based on weight during time_id-1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从Microsoft支持中获得了解决方案,并且可以
将此公式放入E2中,然后拖动
= if($ b2 = 0,0,countifs($ b $ 2:$ b $ 100,索引($ b $ 2:$ b $ $ 100,行(2:2)-4),$ c $ 2:$ c $ 100,”&gt ;“& index($ c $ 2:$ c $ 100,行(2:2)-4))+1)
Got the solution from Microsoft support and it works-
Put this formula in E2 and drag down
=IF($B2=0,0,COUNTIFS($B$2:$B$100,INDEX($B$2:$B$100,ROW(2:2)-4),$C$2:$C$100,">"&INDEX($C$2:$C$100,ROW(2:2)-4))+1)