Solved

Filter a report based on a sum per group

Posted on 2008-06-19
6
531 Views
Last Modified: 2011-10-19
I've built a report where one of the fields is a sum for each group. I'd like to be able to filter out all the groups where Sum(field)>0 for each group.  I feel like this should be easy, but I'm not totally sure how to do this one.  Thanks in advance!
0
Comment
Question by:steam23
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:bandriese
Comment Utility
Sometimes I have trouble doing this sort of thing my self. What I would suggest is create a query to generate this information. Create a second query, if required, to filter out all the records with zero values, then base your report on the second query. You should be able to just change the Row source in the report without redesigning your report. Your grouped data in the report will then have no groups with zeros.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
Please post the query you are using for this report.
0
 

Author Comment

by:steam23
Comment Utility
Here's my query:

SELECT Students.[Student Name], Students.[Parent Name], Students.[Home Phone], Students.[Business Phone], Students.[Mobile Phone], Schedule.[Formatted time], Schedule.Categories, Schedule.Makeup, Schedule.[Start Time], Students.[Current Status]
FROM Schedule RIGHT JOIN Students ON Schedule.[Student Name] = Students.[Student Name]
WHERE (((Schedule.Categories) Like "*xld*" Or (Schedule.Categories) Like "*Admin mixup*" Or (Schedule.Categories) Like "*NSN*" Or (Schedule.Categories) Like "*mu*" Or (Schedule.Categories) Like "*sick*" Or (Schedule.Categories) Like "*credited*") AND ((Students.[Current Status])="Active"));

In my detail header I have a text box with the value of sum(schedule.makeup) and that's the value i want to filter on.
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

Author Comment

by:steam23
Comment Utility
bandriese: I'm not sure how to do what you're talking about. How do you make a second querry for this case that will filter out those with a 0 sum?
0
 
LVL 3

Accepted Solution

by:
bandriese earned 125 total points
Comment Utility
If you create a query, say QueryA that says:

SELECT * from MyTable WHERE MyField > "0"

Then Create another query that says:

SELECT * from QueryA WHERE MyOtherField = "something"

Now you don't need 2 queries to accomplish what I did above, but if you haven't done this before, it should be noted that you can build queries and have joins (relationships) on queries and well as tables. There are situations in Access where you have to create multiple queries to accomplish one task, for example in some situations using multiple tables with both left and right joins (ambiguous outer joins it's called).

For your query above, why not create two sets of queries. One to do the filtering and one to pull up the records you want to see with a relationship between them. I think in your case it's difficult to filter using just the query above because you're grouping by something on your report and want the sub of schedule.makeup to < or > than whatever is on the form, not schedule.makeup itself.

See the query, "ShowTheRecords" in the attached database. Here I'm showing all orders for any customer where the sum of the PO numbers for all Orders a customer has is greater than 4. Carefull with "FiltertheSum" in design view. Access wants to make the >4 a >"4" which will cause an error, you either need a 3rd query or just remove the quotes in SQL view before you run it.
Sample.mdb
0
 

Author Closing Comment

by:steam23
Comment Utility
Thanks! That did it. I really appreciate the sample file. It helped alot!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now