Index/Match OR VLOOKUP/AVERAGEIF/HLOOKUP to return values

chrono2483

Board Regular
Joined
Aug 23, 2014
Messages
164
Office Version
  1. 2016
Hello Everyone,

I have two sheets: Sheet1 and Sheet2.

Sheet1, contains the raw data.
Sheet2, contains tables with formulas to pull from Sheet1

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
1
Day of Week
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
2
WeekNum
1
1
1
1
1
1
1
2
2
2
2
2
2
2
3
Name
1-Jan-17
2-Jan-17
3-Jan-17
4-Jan-17
5-Jan-17
6-Jan-17
7-Jan-17
8-Jan-17
9-Jan-17
10-Jan-17
11-Jan-17
12-Jan-17
13-Jan-17
14-Jan-17
4
Paula Smith
-
-
-
23
26
30
-
45
65
99
99
-
-
-
5
John Doe
56
57
88
98
76
44
56
44
43
41
38
36
39
40
6
Jane Doe
99
99
99
100
101
111
112
79
77
74
100
101
112
99
7
Craig Lowes
8
Peter Oz

<tbody>
</tbody>








;

What I would like to do is have a formula that will do similar to a VLOOKUP to match the name of the client. Then, based on the weeknum, do an AVERAGEIF of all the values that fall within that range, for that name. What it will return is the average for that week, for that client.

Example: John Doe would return 67.8, for Week 1 // Jane Doe would return 103 for Week 1 // Paula Smith would return 77, for Week 2.

I've been playing around with this formula that works in a similar scenario, with no success:

=IFERROR(VLOOKUP($A$5,Sheet1!$A:$A,AVERAGEIF(SUMPRODUCT(--(Sheet1!$2:$2=Sheet2!$C$1),Sheet1!7:7)),FALSE),0)

Where $A$5 = Client's name, $C$1 = Week Number


Am I missing something with my formula? Any help would be great. TY!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try array entering this formula. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.


Excel 2012
ABCDEFGHIJKLMNO
1Day of WeekSundayMondayTuesdayWednesdayThursdayFridaySaturdaySundayMondayTuesdayWednesdayThursdayFridaySaturday
2WeekNum11111112222222
3Name1/1/20171/2/20171/3/20171/4/20171/5/20171/6/20171/7/20171/8/20171/9/20171/10/20171/11/20171/12/20171/13/20171/14/2017
4Paula Smith---232630-45659999---
5John Doe5657889876445644434138363940
6Jane Doe99999910010111111279777410010111299
7Craig Lowes
8Peter Oz
9
10
11
12John Doe67.85714
131
Sheet1
Cell Formulas
RangeFormula
B12{=AVERAGE(IF(($A$4:$A$8=A12)*(A13=B2:O2),$B$4:$O$8))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Try array entering this formula. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.

Excel 2012
ABCDEFGHIJKLMNO
1Day of WeekSundayMondayTuesdayWednesdayThursdayFridaySaturdaySundayMondayTuesdayWednesdayThursdayFridaySaturday
2WeekNum11111112222222
3Name1/1/20171/2/20171/3/20171/4/20171/5/20171/6/20171/7/20171/8/20171/9/20171/10/20171/11/20171/12/20171/13/20171/14/2017
4Paula Smith---232630-45659999---
5John Doe5657889876445644434138363940
6Jane Doe99999910010111111279777410010111299
7Craig Lowes
8Peter Oz
9
10
11
12John Doe67.85714
131

<tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
B12{=AVERAGE(IF(($A$4:$A$8=A12)*(A13=B2:O2),$B$4:$O$8))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



Thanks FlameRetired!

I've tried the above - and it does return a value [i had to define the search range for the name ie. A4:A8 instead of A:A]. However, the value returned is not the average of the range in question.

Any idea/workaround?
 
Last edited:
Upvote 0
Thanks FlameRetired!

I've tried the above - and it does return a value [i had to define the search range for the name ie. A4:A8 instead of A:A]. However, the value returned is not the average of the range in question.

Any idea/workaround?




++ I played around with my ranges, and was able to get it to work. Thank you so much - works perfectly!!! :)
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,591
Members
449,089
Latest member
Motoracer88

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