Array formula to find results based on multiple search criteria

Pigmy

New Member
Joined
Mar 3, 2010
Messages
24
Hi,

I'm trying to construct a table that shows what project was being undertaken at a particular time by an individual. My input table comes from a system that tells me the individual name, the project they were working on and the time they started and finished. So where an individual has been working on multiple projects they will have multiple entries against their name.

I've split the input data into 5 min slots and created a sheet called Calculator that now shows their projects in column A, their names in column B and the times along row 1 and populates the project they were working on in the appropriate cell. Where they weren't working on a project, these cells have a 0 in them (though could easily be changed to a "" or 1 if it helps). At this stage, a person still appears multiple times in column B and projects occur multiple times in column A, however a person cannot be working on 2 projects at the same time.

I then want to create a table called Re-Calc showing everyone who was working on a specific day and what they were working on (with a view to colour coding the different projects). I've used
Code:
{=IFERROR(INDEX(Calculator!$B$2:$B$500, MATCH(0,COUNTIF($A$1:A1, Calculator!$B$2:$B$500), 0)),"")}
to generate a unique list of people in column A and I have the times along the top in row 1.

So I want to write a formula to find where the person's name matches the values in Calculator!column B, the time in row 1 matches the times in Calculator!row 1 and then return the first non-blank entry from the corresponding table. However I'm struggling with the Match function as it only finds the 1st match with the person's name. I've being struggling with this for a while now so think I've started going off on a tangent and therefore need help!

The closest I've got is the below:-
Code:
=SMALL(
IF(
AND(MATCH('Re-calc'!$A3,Calculator!$B$2:$B$500,0),
INDEX(Calculator!BT$2:BT$500,MATCH(FALSE,ISBLANK(Calculator!BT$2:BT$500),0))),Calculator!$BT$1:$BT$500),1)

entered as an array formula, but it just finds the top line of data from Calculator. I guess this is logical as
(MATCH('Re-calc'!$A3,Calculator!$B$2:$B$500,0) its finding the presence of the person's name, not a specific row so I'm now thinking I've gone about this in the wrong way!

Any help appreciated!
 

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.
Hello,

If I understand correctly your sheet's structure ...instead of (MATCH('Re-calc'!$A3,Calculator!$B$2:$B$500,0) ...

you should be using SMALL(IF
(Calculator!$B$2:$B$500='Re-calc'!$A3,Row($B$2:$B$500)),ROWS($1:1))

Hope this will help
 
Last edited:
Upvote 0
Hi James,

Ive tried that - the whole string now loks like:-
Code:
=SMALL(
IF(
AND(
SMALL(IF(Calculator!$B$2:$B$500='Re-calc'!$A3,ROW($B$2:$B$500)),ROWS($1:1)),
INDEX(Calculator!BT$2:BT$500,MATCH(FALSE,ISBLANK(Calculator!BT$2:BT$500),0))),Calculator!$BT$1:$BT$500),1)
However its still just picking up the top line from he Calculator sheet.

Does that make sense?
Thanks
 
Upvote 0
Hi again,

Do you mind listing the conditions :

1. Condition 1
2. Condition 2
3. Condition 3

and confirming the data to be returned is located in range : Calculator!BT$2:BT$500

As mentioned before ... you should not use Match() but instead use If() ...
 
Upvote 0
Hi,

The data is in the table from columns H through to HH (I think). However the first instance I've found where the first person has been working on a second project is in column BT. So yes, the first cell that should give a positive result is in column BT.

The logic I'm trying to write is:-
1 - find all the occurrences in Calculator where the employee whose number is shown in Re-Calc A2 appears in column B. They usually work on 3-4 projects a day so if you image me filtering Calculator based on 1 persons employee number, I'd get about 4 lines showing
2 - Summarise these 4 lines into 1 row with no gaps. So if employee 12345 worked on project X from 09:00 to 10:00 then project Y from 10:30 to 12:00, the top line in Calculator would currently show as a string of 0's up to 09:00 then would have X in each cell until 10:00 and then a further string of 0s. The next line would show a string of 0's up to 10:30, then show Y until 12:00 then a further string of 0's. I'm trying to get these into 1 row. I've tried to show this below:-

Current Calculator sheet
[TABLE="width: 832"]
<colgroup><col width="64" span="13" style="width: 48pt;"></colgroup><tbody>[TR]
[TD="class: xl63, width: 64"]Employee[/TD]
[TD="class: xl63, width: 64"]Project[/TD]
[TD="class: xl64, width: 64"]08:00[/TD]
[TD="class: xl64, width: 64"]08:30[/TD]
[TD="class: xl64, width: 64"]09:00[/TD]
[TD="class: xl64, width: 64"]09:30[/TD]
[TD="class: xl64, width: 64"]10:00[/TD]
[TD="class: xl64, width: 64"]10:30[/TD]
[TD="class: xl64, width: 64"]11:00[/TD]
[TD="class: xl64, width: 64"]11:30[/TD]
[TD="class: xl64, width: 64"]12:00[/TD]
[TD="class: xl64, width: 64"]12:30[/TD]
[TD="class: xl64, width: 64"]13:00[/TD]
[/TR]
[TR]
[TD="class: xl63"]12345[/TD]
[TD="class: xl63"]X[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]X[/TD]
[TD="class: xl63"]X[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[/TR]
[TR]
[TD="class: xl63"]12345[/TD]
[TD="class: xl63"]Y[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]Y[/TD]
[TD="class: xl63"]Y[/TD]
[TD="class: xl63"]Y[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[/TR]
[TR]
[TD="class: xl63"]12345[/TD]
[TD="class: xl63"]Z[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]0[/TD]
[TD="class: xl63"]Z[/TD]
[TD="class: xl63"]Z[/TD]
[/TR]
</tbody>[/TABLE]

Desired output in Re-Calc
[TABLE="width: 832"]
<colgroup><col width="64" span="13" style="width: 48pt;"></colgroup><tbody>[TR]
[TD="class: xl65, width: 64"]Employee[/TD]
[TD="class: xl65, width: 64"][/TD]
[TD="class: xl66, width: 64"]08:00[/TD]
[TD="class: xl66, width: 64"]08:30[/TD]
[TD="class: xl66, width: 64"]09:00[/TD]
[TD="class: xl66, width: 64"]09:30[/TD]
[TD="class: xl66, width: 64"]10:00[/TD]
[TD="class: xl66, width: 64"]10:30[/TD]
[TD="class: xl66, width: 64"]11:00[/TD]
[TD="class: xl66, width: 64"]11:30[/TD]
[TD="class: xl66, width: 64"]12:00[/TD]
[TD="class: xl66, width: 64"]12:30[/TD]
[TD="class: xl66, width: 64"]13:00[/TD]
[/TR]
[TR]
[TD="class: xl65"]12345[/TD]
[TD="class: xl65"][/TD]
[TD="class: xl65"][/TD]
[TD="class: xl65"][/TD]
[TD="class: xl65"]X[/TD]
[TD="class: xl65"]X[/TD]
[TD="class: xl65"][/TD]
[TD="class: xl65"]Y[/TD]
[TD="class: xl65"]Y[/TD]
[TD="class: xl65"]Y[/TD]
[TD="class: xl65"][/TD]
[TD="class: xl65"]Z[/TD]
[TD="class: xl65"]Z[/TD]
[/TR]
</tbody>[/TABLE]

If guessing the second set of criteria I'm using to find the blank cells uses MATCH and therefore should be IF as you suggest

Best regards
 
Upvote 0
Hi,

Based on your example above ...

If your Current Calculator is located in Sheet1 in range A1:M4

and your desired output in Sheet2 in range A1:M2 ...

You can test following Array formula in Sheet2 cell C2 :

Code:
 =IF(MAX(ROW(Sheet1!C2:C4)*(Sheet1!C2:C4<>0))=0,"",INDEX(Sheet1!C1:C4,MAX(ROW(Sheet1!C2:C4)*(Sheet1!C2:C4<>0))))

Hope this will help
 
Upvote 0
Hi

That worked for 1 emloyee but the data inclues several employees like the table below (sorry for not making that clear)

CALCULATOR SHEET
[TABLE="width: 628"]
<colgroup><col width="69" style="width: 52pt; mso-width-source: userset; mso-width-alt: 2523;"> <col width="64" style="width: 48pt;" span="12"> <tbody>[TR]
[TD="width: 69, bgcolor: transparent"]Employee[/TD]
[TD="width: 64, bgcolor: transparent"]Project[/TD]
[TD="width: 64, bgcolor: transparent"]08:00[/TD]
[TD="width: 64, bgcolor: transparent"]08:30[/TD]
[TD="width: 64, bgcolor: transparent"]09:00[/TD]
[TD="width: 64, bgcolor: transparent"]09:30[/TD]
[TD="width: 64, bgcolor: transparent"]10:00[/TD]
[TD="width: 64, bgcolor: transparent"]10:30[/TD]
[TD="width: 64, bgcolor: transparent"]11:00[/TD]
[TD="width: 64, bgcolor: transparent"]11:30[/TD]
[TD="width: 64, bgcolor: transparent"]12:00[/TD]
[TD="width: 64, bgcolor: transparent"]12:30[/TD]
[TD="width: 64, bgcolor: transparent"]13:00[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]12345[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]22222[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]12345[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]33333[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]12345[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]33333[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]44444[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[/TR]
</tbody>[/TABLE]

DESIRED OUTPUT
[TABLE="width: 628"]
<colgroup><col width="69" style="width: 52pt; mso-width-source: userset; mso-width-alt: 2523;"> <col width="64" style="width: 48pt;" span="12"> <tbody>[TR]
[TD="width: 69, bgcolor: transparent"]Employee[/TD]
[TD="width: 64, bgcolor: transparent"]Project[/TD]
[TD="width: 64, bgcolor: transparent"]08:00[/TD]
[TD="width: 64, bgcolor: transparent"]08:30[/TD]
[TD="width: 64, bgcolor: transparent"]09:00[/TD]
[TD="width: 64, bgcolor: transparent"]09:30[/TD]
[TD="width: 64, bgcolor: transparent"]10:00[/TD]
[TD="width: 64, bgcolor: transparent"]10:30[/TD]
[TD="width: 64, bgcolor: transparent"]11:00[/TD]
[TD="width: 64, bgcolor: transparent"]11:30[/TD]
[TD="width: 64, bgcolor: transparent"]12:00[/TD]
[TD="width: 64, bgcolor: transparent"]12:30[/TD]
[TD="width: 64, bgcolor: transparent"]13:00[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]12345[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"]Z[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]22222[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"]X[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]33333[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Y[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[TD="bgcolor: transparent"]Z[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]44444[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent"]F[/TD]
[/TR]
</tbody>[/TABLE]

Hopefully that makes more sense. Thanks for helping
 
Upvote 0
Hi again,

Based on the same assumptions as earlier ...

In cell A2

Code:
=IFERROR(INDEX(Sheet1!$A$2:$A$8,MATCH(0,COUNTIF($A$1:A1,Sheet1!$A$2:$A$8),0)),"")

and in cell C2

Code:
=IF(MAX(ROW(Sheet1!C$2:C$8)*(Sheet1!C$2:C$8<>0)*(Sheet1!$A$2:$A$8=Sheet2!$A2))=0,"",INDEX(Sheet1!C$1:C$8,MAX(ROW(Sheet1!C$2:C$8)*(Sheet1!C$2:C$8<>0)*(Sheet1!$A$2:$A$8=Sheet2!$A2))))

Hope this will help
 
Upvote 0
Pleased to hear it is all sorted out ...

Thanks for your Thanks ...
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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