gpt4 book ai didi

sql-server - Excel 2016 复杂嵌套 IF

转载 作者:行者123 更新时间:2023-12-04 21:56:26 25 4
gpt4 key购买 nike

我正在使用超过 2,000 行的 Excel 工作表。我附上的图片显示了这个问题。我已经检查了 StackOverflow 上的问题,我没有看到任何解决这种情况的方法:

Snapshot that illustrates the situation

我需要一个公式来计算 E 列中的百分比(E 被格式化为百分比)。我可以在逻辑上手动完成此操作,但需要 15 分钟以上,并且需要每天生成报告。该列表来自 SQL Server,我也无法让我的 SQL 查询来处理这个问题,也无法让它在 VBA for Excel 中工作。

单元格 E3 的逻辑:

If C2='house' and C3='house' and C4='house', then '100'
If C2='house' and C3='house' and C4='prospect', then 'C3/SUM(C3:C4)'
If C2='house' and C3='prospect' and C4='house', then 'C3/SUM(C2:C3)'
If C2='house' and C3='prospect' and C4='prospect', then 'C3/SUM(C2:C3)'
If C2='prospect' and C3='prospect' and C4='prospect', then '100'
If C2='prospect' and C3='house' and C4='house', then, '100'
If C2='prospect' and C3='house' and C4='prospect', then 'C3/SUM(C3:C4)'
If C2='prospect' and C3='prospect' and C4='house', then '100'



提前感谢您的任何帮助!

最佳答案

显然你的问题中有一个错字,你的意思是用列上的数字计算 D不是 C ,即 D3/Sum(D3:D4)等等

您可以尝试使用嵌套的 if 简单地编写该逻辑......但我意识到这个看起来像数字逻辑练习的规则实际上要简单得多。总之,该等式应该检测从“House”到“Prospect”的翻转,如果有的话。

试试这个公式 E3并将其复制下来:

E3:
=D3/(D3+ (D2*(C2="House")*(C3="Prospect")) + (D4*(C3="House")*(C4="Prospect")))

关于sql-server - Excel 2016 复杂嵌套 IF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43813663/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com