Excel 保持原序时计算组内排名

Excel某表格第1列是分组,第2列是日期,未排序。

|----|----------|--------------|
| | A | B |
| 1 | Agent ID | Date of Sale |
| 2 | Agent1 | 07-12-2023 |
| 3 | Agent1 | 05-12-2023 |
| 4 | Agent2 | 09-12-2023 |
| 5 | Agent3 | 13-12-2023 |
| 6 | Agent2 | 14-12-2023 |
| 7 | Agent2 | 22-12-2023 |
| 8 | Agent1 | 15-12-2023 |
| 9 | Agent1 | 17-12-2023 |
| 10 | Agent2 | 13-12-2023 |
| 11 | Agent1 | 20-12-2023 |
| 12 | Agent1 | 18-12-2023 |
| 13 | Agent3 | 20-12-2023 |
| 14 | Agent3 | 09-12-2023 |

要求在保持原序的情况下,算出每组数据的内部排名,写在第3列:

|----|----------|--------------|--------|
| | A | B | C |
| 1 | Agent ID | Date of Sale | result |
| 2 | Agent1 | 07-12-2023 | 2 |
| 3 | Agent1 | 05-12-2023 | 1 |
| 4 | Agent2 | 09-12-2023 | 1 |
| 5 | Agent3 | 13-12-2023 | 2 |
| 6 | Agent2 | 14-12-2023 | 3 |
| 7 | Agent2 | 22-12-2023 | 4 |
| 8 | Agent1 | 15-12-2023 | 3 |
| 9 | Agent1 | 17-12-2023 | 4 |
| 10 | Agent2 | 13-12-2023 | 2 |
| 11 | Agent1 | 20-12-2023 | 6 |
| 12 | Agent1 | 18-12-2023 | 5 |
| 13 | Agent3 | 20-12-2023 | 3 |
| 14 | Agent3 | 09-12-2023 | 1 |

使用 SPL XLL

复制代码
=spl("=E(?).derive(#:id,rk).sort(#1,#2).run(rk=rank(#2;#1)).sort(id).(rk)",A1:B14)

函数 E 将片区转为表格,derive 增加新列,rank 计算排序后的组内记录的排名,# 是行号,#1 是第 1 列。

免费下载试用

相关推荐
柯南二号14 分钟前
【Java后端】MyBatis-Plus 原理解析
java·开发语言·mybatis
我是哈哈hh34 分钟前
【Node.js】ECMAScript标准 以及 npm安装
开发语言·前端·javascript·node.js
Sammyyyyy2 小时前
2025年,Javascript后端应该用 Bun、Node.js 还是 Deno?
开发语言·javascript·node.js
William一直在路上3 小时前
Python数据类型转换详解:从基础到实践
开发语言·python
看到我,请让我去学习3 小时前
Qt— 布局综合项目(Splitter,Stacked,Dock)
开发语言·qt
GUET_一路向前3 小时前
【C语言防御性编程】if条件常量在前,变量在后
c语言·开发语言·if-else·防御性编程
曳渔4 小时前
UDP/TCP套接字编程简单实战指南
java·开发语言·网络·网络协议·tcp/ip·udp
三千道应用题4 小时前
WPF&C#超市管理系统(6)订单详情、顾客注册、商品销售排行查询和库存提示、LiveChat报表
开发语言·c#·wpf
hqxstudying4 小时前
JAVA项目中邮件发送功能
java·开发语言·python·邮件
咪咪渝粮4 小时前
JavaScript 中constructor 属性的指向异常问题
开发语言·javascript