VLOOKUP on multiple criteria

Nadja273

New Member
Joined
Feb 28, 2019
Messages
2
Hi,

I have a large dataset detailing attendance over time at a leisure centre. At the moment, my data is organised as the calendar week in the top row, with each member’s number of visits in the rows below. Now I would like to restructure my data and organise it as visits in the first month, second month etc. I want to get this output in a separate sheet that is slightly different, and may contain only a sub-sample of member IDs from this table.

This is an example of how this data looks:

IDMembership StartMembership END1 20182 20183 20184 20185 20186 2018
12 20182 201923243
23 20181212
31 20185 20181111

<tbody>
</tbody>

To now convert this data into visits during the 1st month of their membership, 2nd month, and so on, I need to come up with a formula to first match the ID in both sheets (if there is a match...), and then match the membership start week with the top row, to then find the value where both variables intersect, and summarise the following 4 cells.

This is what I want the new table to look like:

IDVisits 1st monthVisits 2nd monthVisits 3rd monthVisits 4th month
11181211
26453
34

<tbody>
</tbody>

To make this even more complicated, I need to be careful about not returning 0’s into the new dataset, when there is no entry due to the termination of the membership. In this case the target cell needs to be blank.

As I have a very large dataset, I am trying to do all this in one go (or in as little steps as possible). I tried different combinations of IF functions and VLOOKUPS and HLOOKUPs, but am overwhelmed by the complexity of the question and nesting the criteria into each other, and was hoping somebody has an idea how to solve this issue?

Any help would be appreciated!

Thanks!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Welcome to the Board!

Put this formula in B2 of your second sheet:

Code:
=IFERROR(1/(1/SUM(OFFSET(Attendance!$D$2,MATCH($A2,Attendance!$A$2:$A$100,0)-1,MATCH(VLOOKUP($A2,Attendance!$A$2:$B$100,2,0),Attendance!$D$1:$Z$1,0)+4*(COLUMNS($B2:B2)-1)-1,1,4))),"")

Change the ranges (and sheet name) to match your workbook. Drag down and across as needed.
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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