Solved

Filter a report based on a sum per group

Posted on 2008-06-19
6
546 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 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
Technology Partners: 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 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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 …

740 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