Results 1 to 3 of 3
  1. #1
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153

    Add a "Percentage" field in a query based of the total of a field


    I currently have a query that counts up all the different types of "Return Methods" from customers. Here is an example of what I currently have:

    Click image for larger version. 

Name:	Untitled1.png 
Views:	15 
Size:	2.4 KB 
ID:	28362

    What I want to do is add a thrid column that converts the count, to a percentage, of the total. Here is an example (in YELLOW) of what i'd like to add to this qry:

    Click image for larger version. 

Name:	Untitled.png 
Views:	15 
Size:	5.1 KB 
ID:	28363
    The new "%" column would take the count of 1 field and divide that by the sum of the entire column.

    I have searched all over, but I cannot find out how to do this. Also as an FYI, I am not familiar with SQL if its possible id like to be able to add this using 'Design View". But I am open to the easiest solution. Thanks!

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    One way is to create a new query, off of this query.
    You can use the DSUM function to get the total Count, and divide each Count by this total count (see: https://www.techonthenet.com/access/...omain/dsum.php).
    If you leave the Criteria expression (it is optional), it will give you the Total.

    You may be able to do it in your one query if you use the DCOUNT function (see: https://www.techonthenet.com/access/...ain/dcount.php)

    If you need help getting it to work, please change your existing query to SQL View, and copy and paste the SQL code of that query here.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Easily done in a report. You can even use the raw data records as the report RecordSource. Set group section on the "Return Methods" field.

    Put a textbox in report header or footer with expression: =Count(*).

    Then textbox in group section can refer to the report header/footer textbox.

    In group footer: =Count(*)/[report textbox name]

    You can show or hide the Detail section containing the raw data records.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 19
    Last Post: 03-09-2017, 09:48 AM
  2. Replies: 4
    Last Post: 12-20-2015, 12:16 PM
  3. Replies: 8
    Last Post: 07-13-2015, 12:51 PM
  4. Query showing name field when "Total" field is zero
    By Gabriel2012 in forum Queries
    Replies: 3
    Last Post: 04-02-2013, 12:50 PM
  5. Replies: 6
    Last Post: 12-28-2012, 02:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums