Results 1 to 7 of 7
  1. #1
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28

    Calculating the column value


    Hi,

    I have a table as shown below

    ColumnA
    2
    3
    5
    6
    1

    I would like to write a query to get the new columnB as shown below

    ColumnB
    2/(2+3+5+6+1)
    3/17
    5/17
    6/17
    1/17

    Can any one you please let me know on how to do this using a query. Thanks.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Probably using a DSum() function but it would be painfully slow. Is this just an exercise or is there a real world application. A report can do it with little difficulty.

  3. #3
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28
    It is a real world application. I just have to display values like
    [ColumnA] [ColumnB=valueofEachRow/SumofallvaluesinRow in ColumnA] [ColumnC = logarithmicValueofEachRow in ColumnB i.e log(ColumnB)]. I think if i can get ColumnB, i can easily get ColumnC. You are suggesting about DSum can we do this in a query?. Please let me know. Thanks.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    This is an exercise for a spread sheet rather than a Database.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Maybe something like:

    SELECT [Table1].[FieldA], [Table1].[FieldA] / Dsum("FieldA","Table1") As [PercentOfTotal] FROM [Table1];

  6. #6
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28
    This is what i'm looking for. I made some unsuccessful attempts with sum, but Dsum comes to the rescue. Thanks a lot.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Glad to help.

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

Similar Threads

  1. Calculating Downtime
    By MFS in forum Access
    Replies: 1
    Last Post: 04-28-2009, 11:59 AM
  2. Help requested for calculating age
    By techexpressinc in forum Queries
    Replies: 3
    Last Post: 01-28-2009, 11:29 AM
  3. Calculating a sum on a report
    By missourijc in forum Reports
    Replies: 0
    Last Post: 10-30-2008, 07:21 PM
  4. Calculating Values
    By Jahan in forum Queries
    Replies: 1
    Last Post: 07-09-2006, 09:15 AM
  5. inserting values in column based another column
    By wasim_sono in forum Database Design
    Replies: 1
    Last Post: 06-27-2006, 05:23 AM

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