基于OrdQty权重平均分配Act Qty的技术实现需求
需求说明
按Name、Color分组,基于OrdQty计算权重平均值,以此分配Act Qty并新增Weightage列。
原始数据表
| SNo | Name | Color | Ref no | OrdQty | Act Qty |
|---|---|---|---|---|---|
| 1 | Ankur | Red | 1.1 | 80 | 120 |
| 2 | Ankur | Red | 1.2 | 30 | 120 |
| 3 | Neeraj | Black | 1.1 | 50 | 110 |
| 4 | Neeraj | Black | 1.2 | 50 | 110 |
| 5 | Neeraj | Red | 1.3 | 30 | 28 |
预期结果表
| SNo | Name | Color | Ref no | OrdQty | Act Qty | Weightage |
|---|---|---|---|---|---|---|
| 1 | Ankur | Red | 1.1 | 80 | 120 | 87 |
| 2 | Ankur | Red | 1.2 | 30 | 120 | 33 |
| 3 | Neeraj | Black | 1.1 | 50 | 110 | 55 |
| 4 | Neeraj | Black | 1.2 | 50 | 110 | 55 |
| 5 | Neeraj | Red | 1.3 | 30 | 28 | 28 |
计算示例与公式
示例计算表
| S | Name | COl | Ref | OrdQty | Act Qty | 计算公式 | 结果 |
|---|---|---|---|---|---|---|---|
| 1 | Ankur | Red | 1.1 | 80 | 120 | (80/110)*120 | 87 |
| 2 | Ankur | Red | 1.2 | 30 | 120 | (30/110)*120 | 33 |
通用公式
Weightage = (OrdQty / 分组内OrdQty总和) * Act Qty
对应示例计算:
(80/110)*120 = 87 (30/110)*120 = 33
内容的提问来源于stack exchange,提问作者wfxasb
相关产品推荐
相关产品推荐

