How to use SUMIFS on two different data tables?

Waimea

Active Member
Joined
Jun 30, 2018
Messages
465
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have two data tables, one for 2017 and one for 2018. Next year I'll have another table for 2019.

I am using named ranges for column names and I am using the named ranges in SUMIFS formula.

However, since there are two different tables I can't figure out how to use SUMIFS to either check data for 2017 och for 2018.

Data table 1 has a column named years in it and all entries are 2017. And data table 2 has a column named years in it and all entries are 2018.


How can I use nested if statements to SUMIFS from 2017 table or from 2018 table, depending on a activex dropdown that is named DashboardYears.

So IF I select 2017 I want to SUMIFS from the 2017 year table. IF I select 2018 I want to SUMIFS from the 2018 year table.

Is there a good way to do this?




Ps. I have though about a mastertable with 2017 and 2018 year tables are in the same table but I want to keep them separate.

Code:
=IF(DashboardYears="2017"; Value if true; Value if false )

Code:
=IF(DashboardYears="2017"; SUMIFS for 2017;  SUMIFS FOR 2018)

But I am not sure how this would work for 2019 also?
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Depending on how many individual sumifs you need I would suggest you try Indirect function for the ranges. If you are using proper tables just build the columns you need to ref in text and add the year variable as a cell reference inside the concatenated string. Then use the string in your indirect functions
 
Upvote 0
Hi Swayzy,

thank you for your reply!

I am using
Code:
=OFFSET(2017!$D$2; 0; 0; COUNTA(2017!$C:$C)-2; 1)

To get my named ranges,

what I am asking is how to use IF formula or other formula to get the right data when I select the activex combobox?
 
Upvote 0
If you need the data in separate tables I would advise you to use the real table function (ctrl + t). Doing so makes it easier to reference them and the ranges auto expand when you enter new data. Hassle free and easy for other to follow.

If you have different named ranges for the different sheets then I would create a lookup table with years in the first column and the named ranges in the second. Then use an index match inside the indirect function that fetches the right range name.

If you havent already looked into indirect I suggest you do so. It can take a string that looks like a range reference and pass it to functions as a true range.
 
Upvote 0
Hi Swayzy,

thank you for your reply and for your suggestions!

I know some things about INDIRECT function and I will try it out!

Could you explain more about your lookup table? (With years in the first column and the named ranges in the second column)
 
Upvote 0
When a user selects a year to look at and you have the data in separate ranges/sheets then you need to alter the referenced named ranges. So if a user switches from 2018 to 2019 then the lookup inside the indirect Will Go to this table and fetch the corresponding named range. If the named ranges are intuitive then you can use just One column with those names. If you use a true table for the reference list then you can add a name and the dropdown Will expand automatically. The table function is there to replace simple named ranges of data tables.

For instance in your situation you have same type of data for each year but you want it separate. Then you would only need to copy the table, rename it to reflect a new year. Then you can through the indirect function build the reference string by spiltting the string at the year part and there you reference the selected year. Then everthing is very easy to update. I can post more exact tomorrow when I am at my computer
 
Upvote 0
Hello Swayzy,

thank you for your reply!

I think I understand what you mean and I would very much like another post from you tomorrow when you are near a computer!
 
Upvote 0
Hello Swayzy,

thank you for your reply!

I think I understand what you mean and I would very much like another post from you tomorrow when you are near a computer!


I made a simple mockup file. Here you should be able to follow the example and see why this is a very optimized structure as long as you dont try to build a big table with the sum functions that use indirect. So if you have a summary overview that you want to be able to easy go back in and check the history the only thing you need to do is when you copy either the entire sheet or just the data table is to change the name to include the new year and be sure that the new year gets added to reference.

https://www.dropbox.com/s/fs5x76pm3s6gq3x/Sum with indirect.xlsx?dl=0
 
Upvote 0
Hi Swayzy,

thank you for your reply!

I see what you did there and I got it to work with your suggestion!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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