Sumproduct formula for multiple criteria vlookup to source tab

Jon3sy

Board Regular
Joined
Jan 30, 2013
Messages
100
Office Version
  1. 365
I have two tabs of data = main tab where I'm writing the formula+ additional source data that has matching specific criteria (record #, field label, Funding type - revex or capex), I am wanting my formula to return value from Column c of source file if it meets the first 3 arguments (Code matches source tab in column A and Actual LTD and Revex - use col C value, if 3rd criteria =Capex use col D value). Not having much luck - been a while since have had to write formulas. Appreciate anyone's help.

=SUMPRODUCT(('Test 2 MonitorData'!$A2='Additional test data2'!$A$2:$A$25000)*('Additional test data2'!$B$2:$B$25000="Actual LTD (Life to Date)")*(('Test 2 MonitorData'!$E2="Revex")*('Additional test data2'!$C2))+('Test 2 MonitorData'!$E2="Capex")*('Additional test data2'!$D2))

In the main tab the lookup value for funding type is in a single column whereas in the source file below it is split out.
Job CodeCost typeREVEXCAPEX
KI000133Total EAC (All Years)31,444.100
KI000133Actual LTD (Life to Date)31,444.100
KI000133ETC YE00
KI000133Actual CY10,2950
KI000133EAC CY10,2950
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi Jonesy,

This is a wee bit confusing... You say you have three arguments to check against, yet you only list two. Also, the headers you list for the source data don't match up with the code you've written nor the example written:

matching specific criteria (record #, field label, Funding type - revex or capex)
Seems like those are the headers for Source Data but they don't match the table shown nor the columns in your formula (You're looking at Column E but you only have three headers in your description). Very hard to follow. Perhaps if you showed an example of the source data, it might make more sense to me (Sorry, not trying to be rude, just prefacing my solution if it doesn't match what you're looking for).

That being said, I've attempted to solve your problem with what I hope is what you're looking for using SUMIFS rather than SUMPRODUCT.

In my solution, the Source Data Column Headers match the table shown in your example.

For the REVEX Column:
=SUMIFS('Source Data'!C:C,'Source Data'!$A:$A,'Main Sheet'!$A2,'Source Data'!$B:$B, 'Main Sheet'!$B2)

For the CAPEX Column:
=SUMIFS('Source Data'!D:D,'Source Data'!$A:$A,'Main Sheet'!$A2,'Source Data'!$B:$B, 'Main Sheet'!$B2)

SUMIFS.gif
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also, MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Apologies - in my haste I did not explain very well and I meant 3 criteria/2 arguments (?) it's been a while since I've used complex formula - I have updated my profile regarding the version I am using, but due to our work protocols cannot seem to install addin, so below I will provide the columns from main sheet where the formula needs to go and the column/row data source example is as per above (each single record will have 5 rows of source data).

The main sheet tab has a single line for each job record per each funding type (so some records will have multiple lines - I use KI000359 as my test example as it has two lines) and the formula to sum the Actual spend to date for each record is looking at the rows in the range of data in sheet 2 where column B cost type = "Actual LTD (Life to Date)" - if in main source the funding type in Column B = "Revex" then take the data from column C, if it = "Capex" then take the data from column D. I'm thinking this might need to be an indirect/match formula?

Thanks again in advance.
S

1627332787905.png


1627332713343.png
 
Upvote 0
due to our work protocols cannot seem to install addin,
In that case you can also simply copy/paste a small section of your worksheet into your post. At least that way helpers can still copy that data rather than having to type it all out.

It looks like the data in the source sheet is a formal table so see if this is the sort of thing you are after. Check/edit the table name to match yours.

Jon3sy.xlsm
ABCDE
1Job CodeCost TypeREVEXCAPEXTotal
2JC1Actual LTD (Life to Date)159520679
3JC2ETC YE163602765
4JC3ETC YE3637111074
5JC1ETC YE8698211690
6JC2Actual LTD (Life to Date)8116891500
7JC3Actual CY7058401545
8JC1Actual LTD (Life to Date)8129721784
9JC2Actual CY8529821834
10JC3Actual LTD (Life to Date)2657881053
11JC1ETC YE8464261272
12JC2Actual CY390560950
13JC3Actual LTD (Life to Date)1939101103
Source


Jon3sy.xlsm
ABC
1Job CodeFundingTotal
2JC1Revex971
3JC1Capex1492
Main
Cell Formulas
RangeFormula
C2:C3C2=SUM(FILTER(FILTER(Table1,Table1[#Headers]=B2),(Table1[Job Code]=A2)*(Table1[Cost Type]="Actual LTD (Life to Date)")))
 
Upvote 0
=SUM(FILTER(FILTER(Table1,Table1[#Headers]=B2),(Table1[Job Code]=A2)*(Table1[Cost Type]="Actual LTD (Life to Date)")))
In that case you can also simply copy/paste a small section of your worksheet into your post. At least that way helpers can still copy that data rather than having to type it all out.

It looks like the data in the source sheet is a formal table so see if this is the sort of thing you are after. Check/edit the table name to match yours.

Jon3sy.xlsm
ABCDE
1Job CodeCost TypeREVEXCAPEXTotal
2JC1Actual LTD (Life to Date)159520679
3JC2ETC YE163602765
4JC3ETC YE3637111074
5JC1ETC YE8698211690
6JC2Actual LTD (Life to Date)8116891500
7JC3Actual CY7058401545
8JC1Actual LTD (Life to Date)8129721784
9JC2Actual CY8529821834
10JC3Actual LTD (Life to Date)2657881053
11JC1ETC YE8464261272
12JC2Actual CY390560950
13JC3Actual LTD (Life to Date)1939101103
Source


Jon3sy.xlsm
ABC
1Job CodeFundingTotal
2JC1Revex971
3JC1Capex1492
Main
Cell Formulas
RangeFormula
C2:C3C2=SUM(FILTER(FILTER(Table1,Table1[#Headers]=B2),(Table1[Job Code]=A2)*(Table1[Cost Type]="Actual LTD (Life to Date)")))

This is a new type of formula on me but have replaced with table name per instructions but am getting formula error =SUM(FILTER(FILTER(Additional test data2,Additional test data2[#Headers]=B2),(Additional test data2[Job Code]=A2)*(Additional test data2[Cost Type]="Actual LTD (Life to Date)")))

1627336595836.png
 
Upvote 0
Hey again,

Judging by your example, I think you can accomplish your goal with a nest IF/SUMIF statement.

=IF(B2="REVEX", SUMIF(A8:A23,A2,C8:C23), IF(B2="CAPEX", SUMIF(A8:A23,A2,D8:D23), "There was an error"))

1627337558598.png
 
Upvote 0
Hey again,

Judging by your example, I think you can accomplish your goal with a nest IF/SUMIF statement.

=IF(B2="REVEX", SUMIF(A8:A23,A2,C8:C23), IF(B2="CAPEX", SUMIF(A8:A23,A2,D8:D23), "There was an error"))

View attachment 43579
Thank you, I thought you were on to something for a moment but your formula is not referencing the row label in the data source "Actual LTD (Life to Date)" so is adding all rows of data?
 
Upvote 0
Thank you, I thought you were on to something for a moment but your formula is not referencing the row label in the data source "Actual LTD (Life to Date)" so is adding all rows of data?
Thank you, I thought you were on to something for a moment but your formula is not referencing the row label in the data source "Actual LTD (Life to Date)" so is adding all rows of data?
Being able to expand the data range automatically in the formula as both the source files grow would be helpful too so the formula doesn't have to be manually changed or monitored?
 
Upvote 0
Ah my bad, forgot to add that in. In that case, change the SUMIF to a SUMIFS statement.

=IF(B3="REVEX", SUMIFS($C$8:$C$23,$A$8:$A$23,A3,$B$8:$B$23, "Actual LTD (Life to Date)"), IF(B3="CAPEX", SUMIFS($D$8:$D$23,$A$8:$A$23,A3,$B$8:$B$23, "Actual LTD (Life to Date)"), "There was an error"))

To make the range dynamic, just remove the row references so that the ranges in the SUMIFS are simply the column letter. Like SUMIFS(C:C, A:A, A3, B:B, "Actual LTD (Life to Date)")

1627341462180.png
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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