Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summing two similar rows

Status
Not open for further replies.

allivant

IS-IT--Management
Sep 27, 2010
4
US

I have five columns of data like this:

Col A: State
Col B: County
Col C: City
Col D: Month
Col E: Hours

If A, B, and C all match, I want to sum Col E. So it doesn't matter what D is. I probably won't even show D in the report. I just want one line instead of two or more.

Ex:

Virginia Fairfax Herndon Feb 5
Virginia Fairfax Herndon May 10

Should show:

Virginia Fairfax Herndon 15

I tried grouping but that didn't work. Can anyone help?
 
You should group on state, then county, then city. Place the groupnames in the city group header and suppress GH1 and GH2. Then place the hours field in the detail section and insert a sum at the city group level. Then suppress the details section and the group footers.

-LB
 
Thanks LB, that worked great. Now the only problem I see is sorting by the Hours. We'd like to be able to sort so the Cities with the highest hours are first so a descending list. I can't seem to do this in the Record Sort like I'm used to. I can't get Hours before the State, County, and City groups.
 
Go to report->group sort and select all->select "sum of {table.hours}" as your group sort field, in descending order.

-LB
 
Actually, now that I look at it it's not correct. I've attached two screen shots of before and after.

orig.jpg

sorted.jpg
 
Your screen shots don't clarify the problem. However, because of the group sort, in retrospect I think you should create a formula to group on:

{table.state}+" "+{table.county}+" "+{table.city}

Then insert the sum at the group level and then do the group sort. You can use the actual fields to display in the body of the report instead of the group name, if you wish.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top