Results 1 to 15 of 15
  1. #1
    Ghoni is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    5

    Lightbulb Use Total in the table

    I have a table
    1 12 20 0.16
    2 10 30 0.24
    3 5 25 0.2
    4 7 35 0.28
    5 13 15 0.12
    Total 125


    first column item
    second column price
    third column expenses
    forth column is the percent of the expenses to be calculated

    I need to get the results 0.16,0.24,........

    As ex in the first row 20/125=0.16


    30/125=0.24

    i need to use the total of column to be divided in another column to get the percent of this item from the expence

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Cross posted at: https://www.access-programmers.co.uk...d.php?t=299591
    You are new to both forums and may not be aware that if you cross-post you should state you have done so & provide the link yourself
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    Thanks Ridders52. As long as I worked on a test query to prove/disprove what I had in mind, I might as well post it here.

    Your query needs a calculated field that divides the number by the DSum of the same field as the number comes from;
    e.g.
    SELECT tblMyTable.Nums, Format([Nums]/DSum("Nums","tblMyTable"),"00.00") AS Expr1
    FROM tblMyTable;
    You would have to play with the format to suit.

    This is why you've been called out for cross-posting without declaring you have done so: https://www.excelguru.ca/content.php?184
    Last edited by Micron; 05-05-2018 at 05:32 PM. Reason: correction

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Alternatively, build a report and use its Sorting & Grouping features with aggregate calcs in report and group header/footer. This allows display of raw data as well as summary calcs.
    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.

  5. #5
    Join Date
    Apr 2017
    Posts
    1,792
    Wait!

    Obviously it is some sales table. Now you have used it for last ten years, and made some ten thousand sales. This percent must coming near to zero!

  6. #6
    Ghoni is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    5
    I am new in access so please can any one help what is the exact formula to be written to get the result in the forth column

    Table :cont
    First column :code
    Second column: price
    Third column : LE
    forth column : percent

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Micron has given you an example, just replace with your table and field names.

    I still recommend you build a report instead of trying to do in query.
    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.

  8. #8
    Ghoni is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    5
    Quote Originally Posted by Micron View Post
    Thanks Ridders52. As long as I worked on a test query to prove/disprove what I had in mind, I might as well post it here.

    Your query needs a calculated field that divides the number by the DSum of the same field as the number comes from;
    e.g.
    SELECT tblMyTable.Nums, Format([Nums]/DSum("Nums","tblMyTable"),"00.00") AS Expr1
    FROM tblMyTable;
    You would have to play with the format to suit.

    This is why you've been called out for cross-posting without declaring you have done so: https://www.excelguru.ca/content.php?184
    Can you please write the exact code and tell me where to add it exactly as i am new

    Table name :cont
    First column :code
    Second column: price
    Third column : LE
    forth column : percent

  9. #9
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    It's my policy to stop helping in a thread if there's no acknowledgement from the original poster (OP) when they've been called out for cross posting. To me this means you don't care or don't understand the issue with cross posting - or maybe both. In addition, you have people posting solutions at the other forum, which is a waste of their time too. Others here may not agree with me, and that's fine. But we don't get paid to help and I won't knowingly continue to participate when the OP doesn't address a cross posting that they have been told was done incorrectly.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The code is a query.

    Build a query and use it as the RecordSource for a report.

    Adapt it to your table and field names.

    This is basic Access functionality.

    Make an attempt and then when you have specific issue, post question.
    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.

  11. #11
    Ghoni is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    5
    Quote Originally Posted by Micron View Post
    It's my policy to stop helping in a thread if there's no acknowledgement from the original poster (OP) when they've been called out for cross posting. To me this means you don't care or don't understand the issue with cross posting - or maybe both. In addition, you have people posting solutions at the other forum, which is a waste of their time too. Others here may not agree with me, and that's fine. But we don't get paid to help and I won't knowingly continue to participate when the OP doesn't address a cross posting that they have been told was done incorrectly.

    Sorry but i am new so i just didn't understand what is cross posting , does that mean that i post it in two places ? if yes i just don't know that they are connected

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Yes, you have the same question in multiple forums. It is a courtesy to inform readers you have done this. They are not connected in any way.
    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.

  13. #13
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    Not only multiple forums. It rarely happens but someone might post the same question in 2 or more sections of the same forum. If I'm not mistaken, that is usually frowned upon altogether. If you are not allowed to post links in one forum to the other (because of your status, or whatever) then in the forum that doesn't allow it, you should still declare the fact and state the other forum name(s) and section (e.g. "queries").

  14. #14
    Ghoni is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    5
    Quote Originally Posted by June7 View Post
    Yes, you have the same question in multiple forums. It is a courtesy to inform readers you have done this. They are not connected in any way.

    sorry i don't know

  15. #15
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    OK, now that we have that all cleared up (at least for me). You've been given answers or cautions in posts 3, 5, 7 and 10. If what you're saying in post 8 is that you don't have the knowledge required to create a basic query, then you need to research and read up on the basics. I gave you a working example - all you should have to do is examine it and replace my made up names with yours. From post 3, change Nums to your field name, and tblMyTable to the name of your table. If you have used spaces in those names, special characters (except for underscore _) or started those names with a number, then you have another problem.

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

Similar Threads

  1. Replies: 26
    Last Post: 07-28-2015, 07:52 PM
  2. Replies: 4
    Last Post: 10-10-2014, 02:39 PM
  3. Query % of total within a table
    By DB2010MN26 in forum Queries
    Replies: 2
    Last Post: 12-07-2011, 04:25 PM
  4. Total table from existing table from
    By HectorH in forum Access
    Replies: 2
    Last Post: 07-26-2011, 02:41 PM
  5. Replies: 1
    Last Post: 03-21-2011, 06:01 AM

Tags for this Thread

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