SUMPRODUCT WITH COLUMN SELECTION

Phill032

Board Regular
Joined
Nov 9, 2016
Messages
51
Hi all.. So i am using a sumproduct formula to sum and count data from a table.
However i have my criteria to meet in column A and along the top as headers i have month/Year.
I would like to have a drop down box to select a month/year on my report sheet so that the sumproduct would select that month/year column to read the data.
I can do the dropdown box so im only after the formula, any help or ideas would be greatly appreciated
So ideally i would select 06-2022 for the month on my consolidated report and it would pull through all the data from the below for June, and if i select May the i get May's data.

Category06-202205-202204-202203-202201-2022
Retail Units951031008256
Fleet Units55645
 

Attachments

  • Capture.PNG
    Capture.PNG
    54.3 KB · Views: 2

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I'll assume your month-year headings are in B1:F1 on Sheet1 for a small example. And suppose your dropdown box selection is on Sheet2 in cells C2 where you might choose 06-2022.
Excel Formula:
=INDEX(Sheet1!$B$2:$F$30,,MATCH(Sheet2!$C$2,Sheet1!$B$1:$F$1,0))
would return rows 2:30 on Sheet1 from the column where the match is found with C2 on Sheet2.
...or are you asking for it to pull only the data for Fleet Units and Retails Units?

Edit: changed range in Index

Example with different sheet names:
MrExcel_20220617.xlsx
ABCDEF
1Category \ DateJun-22May-22Apr-22Mar-22Feb-22
2Service15479
3Retail Units86355
4Fleet Units79157
5Other41321
Sheet6

MrExcel_20220617.xlsx
C
1
2
3May-22
4
56
69
7
8
Sheet7
Cell Formulas
RangeFormula
C5:C6C5=INDEX(Sheet6!$B$2:$F$5,{2;3},MATCH(C3,Sheet6!$B$1:$F$1,0))
Dynamic array formulas.

If you know the location of the Retail and Fleet rows, you could hardwire their row index positions into the formula as an array like this.
 
Last edited:
Upvote 0
I'll assume your month-year headings are in B1:F1 on Sheet1 for a small example. And suppose your dropdown box selection is on Sheet2 in cells C2 where you might choose 06-2022.
Excel Formula:
=INDEX(Sheet1!$A$2:$F$30,,MATCH(Sheet2!$C$2,Sheet1!$B$1:$F$1,0))
would return rows 2:30 on Sheet1 from the column where the match is found with C2 on Sheet2.
...or are you asking for it to pull only the data for Fleet Units and Retails Units?
As the data is pulled in through power query i have done a transpose of the table and i think this may have solved my problem.
I will have a go at your example above to see how it works
 
Upvote 0
If you are bringing it in from PQ, and you don't need any other data from your main source, you could add some lines to the M-code that would delete everything but the month, Fleet, and Retail values. If you are bringing over more data and you know where the Retail and Fleet rows are, then the hardwired row index approach in the INDEX/MATCH formula in my last post is convenient. If you don't know the location of the Retail and Fleet rows, then more is needed to do this with a formula (e.g., another MATCH function to find the rows). What version of Excel are you using?
 
Upvote 0
If you are bringing it in from PQ, and you don't need any other data from your main source, you could add some lines to the M-code that would delete everything but the month, Fleet, and Retail values. If you are bringing over more data and you know where the Retail and Fleet rows are, then the hardwired row index approach in the INDEX/MATCH formula in my last post is convenient. If you don't know the location of the Retail and Fleet rows, then more is needed to do this with a formula (e.g., another MATCH function to find the rows). What version of Excel are you using?
Using 365, there are over 200 lines in each of the 2 reports that i need to consolidate.
Some of the criteria in the Category column are named the same, by doing a transpose it has eliminated this problem and i can utilise the month year as dropdown in column A.
The categories become the headers which are fixed into my main report anyway. Thanks for your help but i think i will just go with PQ doing the hard work for now.
 
Upvote 0
Sounds good. Post back if you encounter any difficulties.
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,039
Members
448,940
Latest member
mdusw

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