如何根据两个不同的条件对Excel中的值进行求和?
我在Excel中有以下数据。正如您在上面看到的,每个 ArchID/ConopsID 都链接到不同的 FY,并且每个 FY 都有不同的层。我正在尝试找到一种方法,如果层是 1 或 2,则该值保持不变。但是,如果您看到 ArchID = 700 仅上升到第 3 层,而 ArchID = 300 则上升到第 4 层。我希望如果 ArchID 仅上升到第 3 层,我们将采用第 3 层上显示的值,但如果存在第 4 层,然后我们将第 3 层和第 4 层的值相加(求和),并将其作为新值插入。
例如,对于 ArchID = 322,在 2022 财年,第 3 层中显示的新值应为 8 (2 + 6)。至于 ArchID = 700,在 2022 财年,由于没有第 4 层,因此第 3 层中显示的值将保持为 5。
请告诉我如何解决此问题。
I have the following data in excel. As you can see above each ArchID/ConopsID is linked to different FY and in each FY there are different tiers. I am trying to find a way where if tier is 1 or 2, the value stays the same. However, if you see ArchID = 700 only goes up to tier 3 whereas ArchID = 300 goes to tier 4. I want if an ArchID only goes up to tier 3, we take the value shown on tier 3 but if tier 4 is present, then we add up (sum) the value of tier 3 and 4 and insert that as the new value.
For example, for ArchID = 322, in FY 2022, the new value displayed in tier 3 should be 8 (2 + 6). Where as for ArchID = 700, in FY 2022, the value displayed in tier 3 would stay at 5 since there is no tier 4.
Please let me know how I can solve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个有点冗长的函数(假设您提供了取决于多个要求/字段的值 - 例如 Arch/Conops、FY 和 Tier):
这假设您想要返回第 4 层也有相同的“第 3+4 层总和”——否则只需在该函数末尾引用 E4 而不是 min(E4,3)(这将返回 0),或者简单地在上面的整个函数周围放置一个大 IF (例如,从概念上讲:
IF(Tier>3,“n/a”,上面的函数)
- 但您可以根据要求/期望进行自定义)。此外 - 上面的函数实际上会将与任何大于 3 (5,6, ...) 的层相对应的数字相加(如果存在) - 假设这不是问题,但如果是这样,请按如下方式修改上面的函数:
(通过将 E4 放在末尾来偷懒,这将为第 4 层返回 0,但您可以根据要求使用类似的 if 语句代替上述 E4/cutomize 进行自定义。)
Here is a bit of a lengthy function (given you've provided values that depend upon several requirements/fields - e.g. Arch/Conops,FY & Tier) that works:
This assumes you want to return the same 'tier 3+4 sum' for tier 4 too -- else just reference E4 instead of min(E4,3) at the end of this function (which will return 0 instead), or simply put a big IF around whole function above (e.g. conceptually:
IF(Tier>3, "n/a", function above)
- but you can customize as req./desired).Also - function above will actually sum numbers corresponding to any tier greater than 3 (5,6, ...) if these exist - assuming not an issue but if so modify above function as follows:
(being lazy by putting E4 at the end, which will return 0 for Tier 4, but you can customize using similar if statement in place of E4/cutomize per above as req.)