Need to pull a min or max date from multiple criteria

xxrichbxx

New Member
Joined
Sep 2, 2015
Messages
49
Office Version
  1. 365
Platform
  1. Windows
Hello, currently pulling my hair out !

I am wanting to pull the earliest start date and the latest completion date into a report which should hopefully give a span of the activities.

I am currently using a vlookup/index match to pull the the data together which is great if there is just one entry for each line, but when there are multiples it becomes a bit of a problem.

I have attached an extract from my spreadsheet.

Columns O - S is my data set and Columns A - G are where I would like to see my extracted data.

Not that the Crane/MEWP min & Max needs to return into columns D&E and the Access Permits return in Columns F&G. The Raw data is held in Columns R&S

Thanks for looking and hopefully this is pretty straight forward.

Min MAx.xlsx
ABCDEFGHIJKLMNOPQRST
1 Crane/MEWPAccess_Permits
2Unique Ref (Crane/MEWP)Unique Ref (Access Permit)Client RefStart Scheduled DateScheduled Completion DateStart Scheduled DateScheduled Completion DateUnique RefActivityClient RefStart Scheduled DateScheduled Completion Date
3237924Crane_MEWP237924Access_Permits237924237924Crane_MEWP303706_237924_1_Crane/MEWP_323792416/07/202323/07/2023
4238013Crane_MEWP238013Access_Permits238013237924Crane_MEWP303706_237924_1_Crane/MEWP_1237924
5237924Crane_MEWP303706_237924_1_Crane/MEWP_223792412/02/202319/02/2023
6237924Access_Permits303706_237924_1_Access Permits_223792416/07/202323/07/2023
7237924Access_Permits303706_237924_1_Access Permits_123792412/02/202316/02/2023
8238013Access_Permits96152_238013_1_Access Permits_123801327/04/202204/05/2022
9238013Access_Permits96152_238013_1_Access Permits_223801312/04/202212/04/2022
10238013Access_Permits96152_238013_1_Access Permits_323801303/05/202204/05/2022
11238013Crane_MEWP96152_238013_1_Crane/MEWP_123801329/04/202227/04/2022
12238013Crane_MEWP96152_238013_1_Crane/MEWP_123801328/04/202227/04/2022
13
14
Sheet1
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
try this:
Book3
ABCDEFGOPQRS
1 Crane/MEWPAccess_Permits
2Unique Ref (Crane/MEWP)Unique Ref (Access Permit)Client RefStart Scheduled DateScheduled Completion DateStart Scheduled DateScheduled Completion DateUnique RefActivityClient RefStart Scheduled DateScheduled Completion Date
3237924Crane_MEWP237924Access_Permits2379242/12/20237/23/20232/12/20237/23/2023237924Crane_MEWP303706_237924_1_Crane/MEWP_32379247/16/20237/23/2023
4238013Crane_MEWP238013Access_Permits2380134/28/20224/27/20224/12/20225/4/2022237924Crane_MEWP303706_237924_1_Crane/MEWP_1237924
5237924Crane_MEWP303706_237924_1_Crane/MEWP_22379242/12/20232/19/2023
6237924Access_Permits303706_237924_1_Access Permits_22379247/16/20237/23/2023
7237924Access_Permits303706_237924_1_Access Permits_12379242/12/20232/16/2023
8238013Access_Permits96152_238013_1_Access Permits_12380134/27/20225/4/2022
9238013Access_Permits96152_238013_1_Access Permits_22380134/12/20224/12/2022
10238013Access_Permits96152_238013_1_Access Permits_32380135/3/20225/4/2022
11238013Crane_MEWP96152_238013_1_Crane/MEWP_12380134/29/20224/27/2022
12238013Crane_MEWP96152_238013_1_Crane/MEWP_12380134/28/20224/27/2022
Sheet1
Cell Formulas
RangeFormula
D3:D4D3=MIN(FILTER($R$3:$R$12,($O$3:$O$12=$A3)*($R$3:$R$12<>"")))
E3:E4E3=MAX(FILTER($S$3:$S$12,($O$3:$O$12=$A3)*($S$3:$S$12<>"")))
F3:F4F3=MIN(FILTER($R$3:$R$12,($O$3:$O$12=$B3)*($R$3:$R$12<>"")))
G3:G4G3=MAX(FILTER($S$3:$S$12,($O$3:$O$12=$B3)*($S$3:$S$12<>"")))
 
Upvote 0
try this:
Book3
ABCDEFGOPQRS
1 Crane/MEWPAccess_Permits
2Unique Ref (Crane/MEWP)Unique Ref (Access Permit)Client RefStart Scheduled DateScheduled Completion DateStart Scheduled DateScheduled Completion DateUnique RefActivityClient RefStart Scheduled DateScheduled Completion Date
3237924Crane_MEWP237924Access_Permits2379242/12/20237/23/20232/12/20237/23/2023237924Crane_MEWP303706_237924_1_Crane/MEWP_32379247/16/20237/23/2023
4238013Crane_MEWP238013Access_Permits2380134/28/20224/27/20224/12/20225/4/2022237924Crane_MEWP303706_237924_1_Crane/MEWP_1237924
5237924Crane_MEWP303706_237924_1_Crane/MEWP_22379242/12/20232/19/2023
6237924Access_Permits303706_237924_1_Access Permits_22379247/16/20237/23/2023
7237924Access_Permits303706_237924_1_Access Permits_12379242/12/20232/16/2023
8238013Access_Permits96152_238013_1_Access Permits_12380134/27/20225/4/2022
9238013Access_Permits96152_238013_1_Access Permits_22380134/12/20224/12/2022
10238013Access_Permits96152_238013_1_Access Permits_32380135/3/20225/4/2022
11238013Crane_MEWP96152_238013_1_Crane/MEWP_12380134/29/20224/27/2022
12238013Crane_MEWP96152_238013_1_Crane/MEWP_12380134/28/20224/27/2022
Sheet1
Cell Formulas
RangeFormula
D3:D4D3=MIN(FILTER($R$3:$R$12,($O$3:$O$12=$A3)*($R$3:$R$12<>"")))
E3:E4E3=MAX(FILTER($S$3:$S$12,($O$3:$O$12=$A3)*($S$3:$S$12<>"")))
F3:F4F3=MIN(FILTER($R$3:$R$12,($O$3:$O$12=$B3)*($R$3:$R$12<>"")))
G3:G4G3=MAX(FILTER($S$3:$S$12,($O$3:$O$12=$B3)*($S$3:$S$12<>"")))
Thank you for your response, it's really appreciated.

I added the formula and it came back with #CALC! if I click on the exclamation it tells me that the array is empty.

The below is in a test spreadsheet which has more data to interrogate. I'm not sure what I have done wrong.

=MIN(FILTER(report1687265521957!$K$2:$K$15000,(report1687265521957!$A$2:$A$15000=$A4)*(report1687265521957!$K$2:$K$15000<>"")))
 
Upvote 0
As written, I don't see any issues, although it is conceivable that the formula is correct but no matches are found. Does report1687265521957!$A$2:$A$15000 contain a list of reference codes? And on the worksheet where the formula appears, $A4 contains a reference code that you know will match at least one value in report1687265521957!$A$2:$A$15000? To confirm, find a known match and note the cell location (let's say the match is found in report1687265521957!$A$22). Then in an open cell on the formula sheet (where the $A4 reference is found), enter
Excel Formula:
report1687265521957!$A$22=$A4
and confirm TRUE is returned. Let me know what you get.
 
Upvote 0
Hi @KRice the sheets I have referenced should definitely have data pulling through. The information attached earlier in the thread was just an extract of the original data.
 
Upvote 0
quick update. I get it to work, but if there is no information then it returns #CALC!. How do I get it to return blank if there is nothing found?

I assume that #CALC! is essentially returning an error as it can't find anything.
 
Upvote 0
Yes, the #CALC! error appears because the FILTER function is finding nothing. Otherwise FILTER returns an array containing all dates that satisfy the filter conditions, and then MIN or MAX operates on that array of values. The FILTER function does take a 3rd argument that describes what should be returned if no values are found, but in this case, I wouldn't use that feature---MIN or MAX will take that value and since the result is formatted as a date, you'll get a nonsensical answer, or if you tell FILTER to return a blank, MIN/MAX will still report a different error because they can't operate on a blank. The easiest approach is to simply wrap your existing formulas inside IFERROR functions, with instructions to return a blank...like this:
Excel Formula:
=IFERROR(MIN(FILTER($R$3:$R$12,($O$3:$O$12=$A3)*($R$3:$R$12<>""))),"")
 
Upvote 0
Yes, the #CALC! error appears because the FILTER function is finding nothing. Otherwise FILTER returns an array containing all dates that satisfy the filter conditions, and then MIN or MAX operates on that array of values. The FILTER function does take a 3rd argument that describes what should be returned if no values are found, but in this case, I wouldn't use that feature---MIN or MAX will take that value and since the result is formatted as a date, you'll get a nonsensical answer, or if you tell FILTER to return a blank, MIN/MAX will still report a different error because they can't operate on a blank. The easiest approach is to simply wrap your existing formulas inside IFERROR functions, with instructions to return a blank...like this:
Excel Formula:
=IFERROR(MIN(FILTER($R$3:$R$12,($O$3:$O$12=$A3)*($R$3:$R$12<>""))),"")
That works perfectly. I just couldn't get the iferror function to work.

Thank you for all of your help.
 
Upvote 0

Forum statistics

Threads
1,215,107
Messages
6,123,126
Members
449,097
Latest member
mlckr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top