Solved

Filter a report based on a sum per group

Posted on 2008-06-19
6
539 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
ID: 21825537
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
ID: 21825688
Please post the query you are using for this report.
0
 

Author Comment

by:steam23
ID: 21825890
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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:steam23
ID: 21826379
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
ID: 21826877
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
ID: 31468940
Thanks! That did it. I really appreciate the sample file. It helped alot!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

948 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

18 Experts available now in Live!

Get 1:1 Help Now