Solved

Access Report: Compute percentage of total for each line

Posted on 2004-04-20
6
556 Views
Last Modified: 2007-12-19
How can I do this on an Access Report:

Header:    Field               Value        Percent
               ----------------------------------------
Detail       Item 1              10           25%
Section:   Item 2              10           25%
               Item 3              20           50%
               ----------------------------------------
Footer:    Total:               40          100%

I haven't played much with using code behind the report to process data line by line but I'm assuming that would be one way.  Any quick pointers or code snippets to get me started quickly would be appreciated.

Thanks,
Tim
0
Comment
Question by:tgraffham
[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
6 Comments
 
LVL 4

Accepted Solution

by:
alexgud earned 125 total points
ID: 10873303
Why don't you put =100*[Value]/Sum([Value]) in the report field for Percent
and for footer just =Sum([Value]) for value and =Sum([Percent]) for percent
0
 
LVL 4

Expert Comment

by:alexgud
ID: 10873490
Sorry, Can't do =Sum([Percent]) but other then this should work
0
 
LVL 16

Expert Comment

by:ahmedbahgat
ID: 10873882
you can create a function to return the percent for each record, and we will pass each record field value as the argument:

in a global module, we create the function:

Function MyPercent(MyValue)
  MyPercent = 100 * MyValue/DSum("[FieldValue]", "MyTable")
End Function

now in the report query create a new column, that will look like this:

ValuePercent: MyPercent([FieldValue])

finaly bound the textbox for the percent to the new column we created


cheers
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 11

Expert Comment

by:sparab
ID: 10875361
are you talking about Access reort from access database ?????
0
 
LVL 11

Expert Comment

by:sparab
ID: 10875436
I" am assuming that this  is Detail report only.

Create query as Test1

SELECT test.field, Sum(test.value) AS SumOfvalue
FROM test
GROUP BY test.field;

Create query for your reports

SELECT test.field, test.value, test1.SumOfvalue
FROM test1 INNER JOIN test ON test1.field = test.field;

Add field and value to your detail part in reports
Add field in Report footer as total with control source as =Sum([value])
Now add new text fields having control source as =Sum([Value])/([Total])
And In Report footer copy the same.

I hope this will help.

Regards
Sparab
=[Value]*100/Sum([Value]) & "%"

If you want to calculate sum and percentage of Value of each group.
0
 
LVL 1

Author Comment

by:tgraffham
ID: 10879534
Thanks for the help.  I don't think my head was on straight considering how simple the solution was.  I had it in my brain that I wouldn't get the correct results if I did aggregate functions at the detail level.  Needless to say, it works fine.

The only thing I had to keep track of was the difference between totals and subtotals.  To divide and get the percent in my group by subtotals, I could just divide my subtotal of [Value] by Sum([Value]) as it would always equal 100%.  Instead I had to make sure to divide the controls rather than the fields: txtSubTotalValue / txtGrandTotalValue.  This works great.

Thanks again,
Tim
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
print previewing the record showing on the form 4 49
Reports issues going from Access 2003 to Access 2013 14 68
access vba 5 55
Batch convert csv to xlsx 10 51
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

737 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