?
Solved

Filter a report based on a sum per group

Posted on 2008-06-19
6
Medium Priority
?
559 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 93

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 500 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

762 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