使用 Excel 中的单元格公式计算完成潜力

问题描述 投票:0回答:1

我正在尝试定义一个单元格内公式来计算 Excel 中的潜在交易完成率。我很难找到解决方案,如果没有解决方案,我希望有人可以提供一些方向。

输入:相邻列中将有两个变量:

  • x 是完成单笔交易所需的秒数
  • y 是事务开始时间之间的秒数

目标: 找出 60 秒内可能完成的总交易完成率,包括 60 秒内可以完全完成的交易数量加上部分完成的交易的总百分比。结果始终为正,但随着

x
y
的增加而接近于零。

新增挑战:

  • 如果
    y
    大于或等于60秒,则只能启动一笔交易
  • 如果
    x
    大于60秒,则每笔交易都是部分完成

解释我想要做的事情的最简单方法是通过示例。

如果将解决方案绘制在时间线上,时间线将如下所示:

Example 1
let x = 30 seconds
let y = 10 seconds
let ti = a transaction where i is the transaction number

t1 starts @ 0 seconds, ends @ 30 seconds == first complete transaction
t2 starts @ 10 seconds, ends @ 40 seconds == second complete transaction
t3 starts @ 20 seconds, ends @ 50 seconds == third complete transaction
t4 starts @ 30 seconds, ends @ 60 seconds == fourth complete transaction
t5 starts @ 40 seconds, time expires @ 60 seconds == (60-40)/30 = 2/3 of a complete transaction
t6 starts @ 50 seconds, time expires @ 60 seconds == (60-50)/30 = 1/3 of a complete transaction

The total transaction completion rate is 1+1+1+1+2/3+1/3 = 5

以下是一些具有各种输入的其他示例。

Example 2
let x = 40 seconds
let y = 10 seconds
let ti = a transaction where i is the transaction number

t1 starts @ 0 seconds, ends @ 40 seconds == first complete transaction
t2 starts @ 10 seconds, ends @ 50 seconds == second complete transaction
t3 starts @ 20 seconds, ends @ 60 seconds == third complete transaction
t4 starts @ 30 seconds, time expires @ 60 seconds == (60-30)/40 = 3/4 of a complete transaction
t5 starts @ 40 seconds, time expires @ 60 seconds == (60-40)/40 = 1/2 of a complete transaction
t6 starts @ 50 seconds, time expires @ 60 seconds == (60-50)/40 = 1/4 of a complete transaction

The total transaction completion rate is 1+1+1+3/4+1/2+1/4 = 4.5

Example 3
let x = 70 seconds
let y = 60 seconds
let ti = a transaction where i is the transaction number

t1 starts @ 0 seconds, time expires @ 60 seconds == (60-0)/70 = 6/7 of a complete
no further transaction starts because y >= 60

Result: 6/7 = ~0.857 

Example 4
let x = 70 seconds
let y = 30 seconds
let ti = a transaction where i is the transaction number

t1 starts @ 0 seconds, time expires @ 60 seconds == (60-0)/70 = 6/7 of a complete
t2 starts @ 30 seconds, time expires @ 60 seconds == (60-30)/70 = 3/7 of a complete
no further transaction starts because y >= 60

Result: 9/7 = ~1.286


Example 4
let x = 10 seconds
let y = 60 seconds
let ti = a transaction where i is the transaction number

t1 starts @ 0 seconds, ends @ 10 seconds == first complete transaction
no further transaction starts because y >= 60

Result: 1

我觉得应该有一个优雅的解决方案,但我还没有找到它。

x
y
小于60时我可以计算完成的总数...

complete = (60 - x)/y + 1

...但这不包括部分完成,并且当 y >= 60 时它不起作用。

我不喜欢使用 VBA,但如果需要,辅助列是可以接受的。

感谢所有想法/建议。

谢谢

excel user-defined-functions
1个回答
0
投票

假设没有版本限制,如您的标签所示,您可以尝试:

  • 在某个单元格中输入,结果将会溢出
=BYROW(
    $A$2:$B$6,
    LAMBDA(arr,
        LET(
            start, SEQUENCE(, 60 / INDEX(arr, 2), 0, INDEX(arr, 2)),
            end, BYCOL(start + INDEX(arr, 1), LAMBDA(arr, MIN(arr, 60))),
            SUM(end - start) / INDEX(arr, 1)
        )
    )
)

© www.soinside.com 2019 - 2024. All rights reserved.