确定最小/最大日期以创建日期范围?

时间:2017-08-11 18:37:05

标签: excel excel-formula excel-2010

我收到了一个包含两列的工作表:日期和周列。

我想要做的是创建一个具有该特定周的日期范围(最小和最大)的附加列。

例如:

+-----------+--------+-------------------+
|   Date    |  Week  |    Date Range     |
+-----------+--------+-------------------+
| 8/1/2017  | Week 1 | 8/1/17 - 8/6/17   |
| 8/2/2017  | Week 1 | 8/1/17 - 8/6/17   |
| 8/3/2017  | Week 1 | 8/1/17 - 8/6/17   |
| 8/4/2017  | Week 1 | 8/1/17 - 8/6/17   |
| 8/5/2017  | Week 1 | 8/1/17 - 8/6/17   |
| 8/6/2017  | Week 1 | 8/1/17 - 8/6/17   |
| 8/7/2017  | Week 2 | 8/7/17 -8/13/17   |
| 8/8/2017  | Week 2 | 8/7/17 -8/13/17   |
| 8/9/2017  | Week 2 | 8/7/17 -8/13/17   |
| 8/10/2017 | Week 2 | 8/7/17 -8/13/17   |
| 8/11/2017 | Week 2 | 8/7/17 -8/13/17   |
| 8/12/2017 | Week 2 | 8/7/17 -8/13/17   |
| 8/13/2017 | Week 2 | 8/7/17 -8/13/17   |
| 8/14/2017 | Week 3 | 8/14/17 - 8/20/17 |
+-----------+--------+-------------------+

逻辑是:找到周等于的最小和最大日期。

我尝试使用这个公式,但它没有按预期工作......

=TEXT(INDEX(MIN($A$2:$A$15), MATCH($B$2:$B$15,$B$2:$B$15, 0)),"mm/dd/yy") & " - " & TEXT(INDEX(MAX($A$2:$A$15), MATCH($B$2:$B$15, $B$2:$B$15, 0)), "mm/dd/yy")

1 个答案:

答案 0 :(得分:2)

如果您有Office 365 Excel:

=TEXT(MINIFS($A$2:$A$14,$B$2:$B$14,B2),"m/d/yyyy") & "-" &TEXT(MAXIFS($A$2:$A$14,$B$2:$B$14,B2),"m/d/yyyy")

enter image description here

2010年

=TEXT(AGGREGATE(15,6,$A$2:$A$14/($B$2:$B$14=B2),1),"mm/dd/yyyy")&" - "&TEXT(AGGREGATE(14,6,$A$2:$A$14/($B$2:$B$14=B2),1),"mm/dd/yyyy")