满足各种条件时仅求最小值。 EXCEL 和/或 SMARTSHEET

Posted

技术标签:

【中文标题】满足各种条件时仅求最小值。 EXCEL 和/或 SMARTSHEET【英文标题】:SUM only min values when various conditions are met. EXCEL and/or SMARTSHEET 【发布时间】:2021-07-29 11:54:27 【问题描述】:

表 1

Initial Score Actions OC Criticality DT Post Score Current Score Responsible Completed Due Date
252 Expand to list actions 105 140
text 6 42 6 252 Jane 100% 10/25/20
text 5 35 4 140 John 100% 10/30/20
text 5 35 3 105 Sam 01/25/21
324 Expand to list actions 135 216
text 6 54 4 216 Cindy 10/15/20
text 5 45 3 135 Roger 12/10/20
288 Expand to list actions 32 192
text 4 32 6 192 Bill 11/21/20
text 2 16 6 96 Karen 100% 01/07/21
text 2 16 2 32 Cindy 02/28/21

注意事项:

在“分数后”列中,粗体单元格(105、135、32)是使用 MIN 函数获得的,范围为正下方的单元格。

我需要什么

我不想对“截止日期”列为空白的“后分数”列中的单元格求和。

仅当“到期日期”早于或等于相应的“日期”(来自表 2)时,我才想对“后分数”列中的单元格求和。但是,如果“后分数”列中有两个或更多单元格符合此条件,那么我只想对每个组的 MIN 值求和(按组,我是指“展开以列出操作”下的每组操作。

我尝试了以下方法:

=SUMIFS(Sum_range,Criteria_range1,Criteria1,Criteria_range2, criteria2)

=SUMIFS([Post Score]2:[Post Score]11,[Due Date]2:[Due Date]11,"")

这将返回“后分数”列中单元格的总和,其中“到期日期”单元格早于或等于相应的“日期”单元格,并且“到期日期”单元格不为空。

但是,我希望它只对 Sum_range 中的 MIN 值求和,这两个条件都满足。

目标:

表 2

Date What the score should be Values that should be added from column "Post Score" Logic
Initial Score 864 252+324+288 SUM of "Initial Score" Column
10/31/20 644 140+216+288 SUM only if "Due Date" in table 1 is before or equal to "Date" in table 2. If there are 2 or more values that meet this condition only SUM the MIN value
11/30/20 548 140+216+192 SUM only if "Due Date" in table 1 is before or equal to "Date" in table 2. If there are 2 or more values that meet this condition only SUM the MIN value
12/31/20 467 140+135+192 SUM only if "Due Date" in table 1 is before or equal to "Date" in table 2. If there are 2 or more values that meet this condition only SUM the MIN value
1/31/20 336 105+135+96 SUM only if "Due Date" in table 1 is before or equal to "Date" in table 2. If there are 2 or more values that meet this condition only SUM the MIN value
2/28/2021 272 105+135+32 SUM only if "Due Date" in table 1 is before or equal to "Date" in table 2. If there are 2 or more values that meet this condition only SUM the MIN value
Final Score 272 105+135+32 SUM cells of column "Post Score" where "Due Date" is Blank

【问题讨论】:

我正在看这个,看看我是否理解它。在表 2 中,对于 2020 年 10 月 31 日,您有 140+216+288。这是因为最后一组中没有没有个日期在 2020 年 10 月 31 日之前,所以你取的是初始分数 (288)? 是的。对于第一组,我取 140,因为这是 2020 年 10 月 31 日之前的两个分数中的最低分数。对于第二组,我取 216,因为这是 20 年 10 月 31 日之前的唯一分数。对于最后一组,我保持初始分数,因为没有分数符合 20 年 10 月 31 日之前的条件。 我认为没有辅助列是不可行的(我在 Google 表格中使用单个公式做了类似的事情,但更灵活一些) 我建议您将post this question 转至Smartsheet Community forum。 Stack Overflow 是询问与编程相关的问题的地方(例如,如果您使用 API 或 SDK 来构建与 Smartsheet 的集成),而 Smartsheet 社区论坛是询问与产品使用相关的问题的地方,例如.论坛中有一个强大的 Smartsheet 专家社区(客户和员工),他们非常适合就您所描述的场景提供反馈。 我有一个使用 Sortby 的可能方法 - 明天会发布一些东西。 【参考方案1】:

这是一个使用 Sortby 的解决方案:

=LET(initScore,FILTER(Table1[Initial Score],Table1[Initial Score]<>""),
filters,(Table1[Due Date]<=[@Date])*(Table1[Due Date]<>""),
groups,MATCH(ROW(Table1[Initial Score]),FILTER(ROW(Table1[Initial Score]),Table1[Initial Score]<>"")),
sortedScore,SORTBY(FILTER(Table1[Post Score],filters),FILTER(groups,filters),1,FILTER(Table1[Post Score],filters),1),
Seq,SEQUENCE(COUNTA(Table1[Initial Score])),
filteredGroups, FILTER(groups,filters),
SUM(IFERROR(INDEX(sortedScore,MATCH(Seq,FILTER(groups,filters),0)),initScore)))

屏幕截图以 2020 年 10 月 31 日为例,显示了 LET 公式中组合在一起的步骤。在表2中,我将日期列中的初始分数和最终分数分别替换为表1中第一个日期的前一个月和表1中最后一个日期后的一个月。

【讨论】:

以上是关于满足各种条件时仅求最小值。 EXCEL 和/或 SMARTSHEET的主要内容,如果未能解决你的问题,请参考以下文章

EXCEL中用函数查找显示同时满足多个条件的最小值和对应数据行的字段内容

[程序员代码面试指南]栈和队列-最大值减去最小值 小于或等于num 的子数组的数量(双端队列)

EXCEL中如何查找区域内满足条件的值,并依次将其对应的值依次输出至指定区域?

如何跨表格取满足条件的某一列数据的最小日期的函数

Excel的现值函数都有哪些(名称和功能 )?

excel中if函数若满足条件返回“是”,不满足条件无返回值怎么写