Nested double vlookup and match function?

donny_benjamin

New Member
Joined
May 13, 2020
Messages
9
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi Everyone,

It's my first time posting and any help with my dilemma will be much appreciated! :-)
I'm working on a new sales report for management. Since it will be updated on a regular basis, I am trying to automate it as much as possible.

My raw data is sorted by month then category instead of category and month (Figure 1, C1 : N2). I created another worksheet to group the categories by month. The challenge has been to find a formula that will retrieve the figures from the raw data tab into the new worksheet. I've tried vlookup, double vlookup, sumifs, and sumproduct functions. I also tried using a helper by combining the month and categories together but to no avail so I created a pivot table instead.

Now I need to create a summary sheet that will retrieve the data by based on month, category (Act, Fcst, etc.), Region and Product and then add a YTD total as show in Figure 3.

Thank you in advance for your help!


Figure 1
1589415409125.png


Figure 2
1589415371421.png


Figure 3
1589415909940.png
 
I noted a few things. In the MTD formula, the last term in the SUMPRODUCT...you want that to cover only the data range from $C$4:$AX$39 rather than $A$4:$AX$39. Note that the other "horizontal" arrays that are constructed also run from C:AX...so you want the data table columns coordinated with them. That got the MTD formulas working.

In the YTD formula, a " 1" is appended to the abbreviated month name in two places to create something that Excel will recognize as a date, so we want something like Jan 1. The space between Jan and 1 is critical, so the formula includes &" 1" (there's a space before the 1)....your version didn't have that. You've specified a large number of columns C:AX, and row 2 holds the month abbreviations. Not all of the cells contain month abbreviations, so DATEVALUE doesn't like that and MONTH doesn't either, so I wrapped the entire construct in an IFERROR and returned a 0 if an error is generated because of the no-data issue. This seems to work and yields an array that looks as it should {1,1,1,1,2,2,2,2,3,3,3,3,0....all 0's}. That final bit seemed to do the trick for the YTD formulas. I haven't finished looking into this---I suspect there is a better way to make the date comparison, but this seems to work.

You may want to make the edits directly in your version after studying the changes I described. Here's the working version:
Book4
ABCDEFGHIJKLMNOPQRSTUVWX
1
23/1/2020
3VLOOKUP(A2,Mapping!$B$24:$C$35,2)
4MarActual UnitsProj2 UnitsBudget UnitsPY Units Actual UnitsProj2 UnitsBudget UnitsPY Units
5Sys A#N/A#N/A
6(Units)ActProjBudgetPYActProjBudgetPY
7US141821434422644
8Europe00000000
9Canada14111425341726
10Japan00000000
11Latin America16661337142623
12EMA1816131329343137
13Greater China1896653253441
14CSA1098922483130
15Total90693659200197165201
16
17Product 1#N/A#N/A
18(Units)ActProjBudgetPYActProjBudgetPY
19US141216219265115
20Europe00000000
21Canada2319728202437
22Japan00000000
23Latin America1817125182141
24EMA81916529363629
25Greater China372119281540
26CSA111118421384131
27Total56537841157156188193
Template
Cell Formulas
RangeFormula
D5D5="MTD "&VLOOKUP($A$2,Mapping!$B$24:$C$35,2,0)
O5O5="YTD "&VLOOKUP($A$2,Mapping!$B$24:$C$35,2,0)
D7:G14D7=SUMPRODUCT((Data!$B$4:$B$39=Template!$A$5)*(Data!$A$4:$A$39=Template!$A7)*(Data!$C$2:$AX$2=Template!$A$4)*(Data!$C$3:$AX$3=Template!D$4)*(Data!$C$4:$AX$39))
O27:R27,D27:G27,O15:R15,D15:G15D15=SUM(D7:D14)
O7:R14O7=SUMPRODUCT((Data!$B$4:$B$39=Template!$A$5)*(Data!$A$4:$A$39=Template!$A7)*(IFERROR(MONTH(DATEVALUE(Data!$C$2:$AX$2 &" 1")),0)<=MONTH(DATEVALUE(Template!$A$4&" 1")))*(Data!$C$3:$AX$3=Template!O$4)*(Data!$C$4:$AX$39))
D17,O17D17=D$5
D19:G26D19=SUMPRODUCT((Data!$B$4:$B$39=Template!$A$17)*(Data!$A$4:$A$39=Template!$A19)*(Data!$C$2:$AX$2=Template!$A$4)*(Data!$C$3:$AX$3=Template!D$4)*(Data!$C$4:$AX$39))
O19:R26O19=SUMPRODUCT((Data!$B$4:$B$39=Template!$A$17)*(Data!$A$4:$A$39=Template!$A19)*(IFERROR(MONTH(DATEVALUE(Data!$C$2:$AX$2 &" 1")),0)<=MONTH(DATEVALUE(Template!$A$4&" 1")))*(Data!$C$3:$AX$3=Template!O$4)*(Data!$C$4:$AX$39))
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi Kirk,
I've tried all the formulas but it still does not compute correctly. After three weeks of this, I'm giving up and will just do it manually for now. Thanks again for all of your help and sorry for the trouble.

Regards,
Don
 
Upvote 0
Have you tried clicking on the clipboard icon in my last post...it's located in the upper left corner at the intersection of row and column labels. You can click that and then paste into a new worksheet in your workbook. You may want to temporarily rename your current "Template" worksheet to "template_original". When you paste, be sure to go to cell A1 on the new sheet and then paste. The formulas should access the 'Data' sheet in that workbook and report back the results.
 
Upvote 0
Same results. The formulas don't compute correctly. I'm sure I'm doing something wrong somewhere along the line but don't know what. Or maybe it simply cannot be done in.
 
Upvote 0
That's puzzling. Here is the entire file that I assembled from your post above where you included the 'Data' and the 'Template' worksheets. Other than resolving the formula issues I described earlier, I hard wired in a date in cell A2 since I didn't have the 'Mapping' sheet (that apparently has some date references on it).
I'm curious if this looks okay when you open it.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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