473,395 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Filter a record on sum of a field

99 64KB
I have a query that gets data from different tables:
Expand|Select|Wrap|Line Numbers
  1. StudentsExams.studentID| StudentsExams.PaperID | Papers.MaxMarks | StudentsExams.ObtdMarks
Then I create a report on this query grouped on StudentID and the Detail contains:
Expand|Select|Wrap|Line Numbers
  1. PaperID | MaxMarks | ObtdMarks | %age (Obtd*100/Max)
The StudentID Footer contains:
Expand|Select|Wrap|Line Numbers
  1. Total: Sum(MaxMarks) | Sum(ObtdMarks) | %age(Sum(ObtdMarks)*100/sum(MaxMarks))
Now I want only those studentID's records where [sum(obtdmarks)*100/sum(maxmarks)>33%.

And I not sure how to do this? Please help me. Thankin in advance!
Nov 26 '14 #1
6 3203
twinnyfo
3,653 Expert Mod 2GB
Although it would be slow, you could use a DSum() Function, in which you use the Criteria you specify. If you have a lot of records, it would be slow.

You could also create a separate report that lists only the students with marks above 33% (criteria in your query), but then you have two reports and I think you want to be able to do this in one (or--you want this report to show only those with >33%)?

It is also difficult to understand what your report looks like, because are you looking for the student's average scores or only those scores >33%. When you are summing values like this, wouldn't you want to average the scores or is it a cumulative score?

Lot's of questions, I know, but your end result is unclear.
Nov 26 '14 #2
mshakeelattari
99 64KB
First of all thanks for your early response. Here is a report
http://s17.postimg.org/cfx0l3ncv/Untitled.png
http://s25.postimg.org/k383kimrj/Untitled.png


On the studentID footer, I get sum of ObtdMarks and sum of MaxMarks and then get the percentage of the ObtdMarks. Now I want those students whose percentage of the total is >33%.
Nov 26 '14 #3
twinnyfo
3,653 Expert Mod 2GB
Again, the only way I know how to do that would be using the DSum() Function which would check the status of each student. Then apply that filter to the report. It's not pretty, but when you are trying to apply a filter to an aggregated value on a Header/Footer, it's just about the only way (that I know of).
Nov 26 '14 #4
jforbes
1,107 Expert 1GB
It looks to me that your calculations and summations are being done by the Report. This works pretty well up until you do something like you are attempting to do, Filter the report based on a summation of a calculated column. Twinnyfo is correct, that you will need to do all these calculations beforehand in the report and then filter on them, if you want to keep all these calculations in the Report.

The other option is to pull all the calculations and summations out of the Report and put them into Queries. To do this
  1. Make a Select Query called something like PaperTotals, based on StudentsExams, link the Papers table, create the calculated columns per Paper (Grade).
  2. Make an Aggregate Query called SubjectTotals, based on PaperTotals and Grouped By SubjectTitle.
  3. Make an Aggregate Query called StudentTotals based on PaperTotals that Groups By Students and Sums up their totals. This is where the Students Overall Grade would be calculated; the one you are looking to filter by.
  4. Make a third Query called StudentInfo that links Students table to the Student Totals, that way all the Student Info is available when you create the Main Report.
  5. Create a SubReport that is based on SubjectTotals. Order it by SubjectTitle, if you want.
  6. Create the MainReport that is based on StudentInfo. You won't need to create headers or footers, unless you want an overall summation on your Students. Then drop in the SubReport so you can see your Students detail by Subject.

Access' Report builder is great for most things, but if attempt to get at top level calculations, you will have trouble.
Nov 26 '14 #5
mshakeelattari
99 64KB
where should I use DSum? in query? please
Nov 29 '14 #6
twinnyfo
3,653 Expert Mod 2GB
You would have a new field in your query in which you use the DSum function based on the values of your r student fields. You would get a value for each record, which should be the same for each student, as you are calculating their total average score. Your query field will look something like this:

Expand|Select|Wrap|Line Numbers
  1. DSum("[ObtdMarks]", "StudentExams", "StudentID = " & [StudentID])/DSum("[MaxMarks]", "StudentExams", "StudentID = " & [StudentID]) AS StudentAvgMarks
This assumes student ID is a numeric value.
Nov 29 '14 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Scott Sabo | last post by:
Hello- I have a table (tblCalls) where I import call stats from an application to. The table has fields: CallID, EmpID, EmpName, CallDate, TotalCalls, etc, etc. On the import process I use...
0
by: Mark Donners | last post by:
I have access 2002 database I like to fill a record field in a table with a text when i click a button I have two tables say table1 and table2. I have a form based on table1, it has a subform...
4
by: | last post by:
Something really common I'm sure and I'm surprised it's not just a field property option. The previous record's field value can be retrieved and copied into the current corresponding field by...
2
by: (PeteCresswell) | last post by:
I've got a screen that has a subform containing an indeterminate number of records. When the user clicks "Change", I put the screen into Edit mode by unlocking all the subform's fields, setting...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
2
by: willyc | last post by:
Hello all, hopefully you will kind enough to offer some assistance.... I want to make what i believe could be quite a complex query, something beyond the 'basic' access queries. I'm not afraid of...
9
subedimite
by: subedimite | last post by:
In VBA Access, How can I read a filed from a table and then read each record in the field and then access each character insided the record for that filed. should I use a split function. I...
14
by: neelsfer | last post by:
I would like to use a combobox and when i add a specific word, it will search for that "word" throughout every record in that specific field of the table. ie 1. Paracetamol 500mg tablets 2. ...
1
by: kaug | last post by:
I have created a report using report viewer to show the record of all employee. I want to filter the record of all employee in a certain department. I want to filter this record as i type the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.