1
votes

I've been given a worksheet with two column: A date and a week column.

What I would like to do is to create an additional column that has the date range (min and max) of that particular week.

So for instance:

+-----------+--------+-------------------+
|   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 |
+-----------+--------+-------------------+

The logic being: find the minimum and maximum date where the week is equal.

I tried using this formula, but it does't work as intended...

=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

1 Answers

2
votes

If you have 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

For 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")