handling range of data from the middle with sumproduct

baseball

Board Regular
Joined
Apr 1, 2002
Messages
153
I have a table of yearly statistics for baseball teams from 1876 through 2001. Each record is the data for a specific team in a specific year, and the several fields in a record show the number of home runs, the number of strikeouts, etc., that the team accumulated for that season.

It's simple to extract the data for a single year using the sumproduct formula, and if I rewrite the formula, I can get all the data from a certain forward or all data before that year.

=sumproduct((A3:A1000=1995)*(B3:B1000="Team")*(C2:C1000)) gets data from 1995 for the variable "Team"
=sumproduct((A3:A1000>=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1995 through 2001
=sumproduct((A3:A1000<=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1876 through 1995

The problem is that the formulas must be changed, which is tedious, and there is no way that I can think of to handle a range of years from the middle, e.g.. 1945-1958. Is there some way to do this with sumproducts and maybe named ranges (FirstYear, LastYear)?

Thanks,
Cliff
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,203
On 2002-09-06 08:35, baseball wrote:
I have a table of yearly statistics for baseball teams from 1876 through 2001. Each record is the data for a specific team in a specific year, and the several fields in a record show the number of home runs, the number of strikeouts, etc., that the team accumulated for that season.

It's simple to extract the data for a single year using the sumproduct formula, and if I rewrite the formula, I can get all the data from a certain forward or all data before that year.

=sumproduct((A3:A1000=1995)*(B3:B1000="Team")*(C2:C1000)) gets data from 1995 for the variable "Team"
=sumproduct((A3:A1000>=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1995 through 2001
=sumproduct((A3:A1000<=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1876 through 1995

The problem is that the formulas must be changed, which is tedious, and there is no way that I can think of to handle a range of years from the middle, e.g.. 1945-1958. Is there some way to do this with sumproducts and maybe named ranges (FirstYear, LastYear)?

Thanks,
Cliff

=SUMPRODUCT((A3:A1000>=E1)*(A3:A1000<=E2)*(B3:B1000="Team")*(C2:C1000))

where E1 houses a year of interest and E2 another with E1 < E2.
 

baseball

Board Regular
Joined
Apr 1, 2002
Messages
153
On 2002-09-06 08:43, Aladin Akyurek wrote:
On 2002-09-06 08:35, baseball wrote:
I have a table of yearly statistics for baseball teams from 1876 through 2001. Each record is the data for a specific team in a specific year, and the several fields in a record show the number of home runs, the number of strikeouts, etc., that the team accumulated for that season.

It's simple to extract the data for a single year using the sumproduct formula, and if I rewrite the formula, I can get all the data from a certain forward or all data before that year.

=sumproduct((A3:A1000=1995)*(B3:B1000="Team")*(C2:C1000)) gets data from 1995 for the variable "Team"
=sumproduct((A3:A1000>=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1995 through 2001
=sumproduct((A3:A1000<=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1876 through 1995

The problem is that the formulas must be changed, which is tedious, and there is no way that I can think of to handle a range of years from the middle, e.g.. 1945-1958. Is there some way to do this with sumproducts and maybe named ranges (FirstYear, LastYear)?

Thanks,
Cliff

=SUMPRODUCT((A3:A1000>=E1)*(A3:A1000<=E2)*(B3:B1000="Team")*(C2:C1000))

where E1 houses a year of interest and E2 another with E1 < E2.

Thanks. That was quick...and easy. I was trying to use the AND function in conjunction with sumproduct, but I didn't think of doing it your way.

Thanks again,
Cliff
 

Watch MrExcel Video

Forum statistics

Threads
1,129,685
Messages
5,637,809
Members
416,983
Latest member
LessThanAverageUser

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
Top