none
Creating A Percentage Column In Query Results RRS feed

  • Question

  • I have a rather simple query whose output is the sum of column1 and the sum of column2.  I'm trying to add a third column to the query results that is in essence:

    SumOfColumn1/(SumOfColumn1+SumOfColumn2) in percentage form

    Any help would be greatly appreciated.  thank you in advance.

    Friday, August 21, 2015 5:02 AM

Answers

  • Hi Karl ... so no sooner did I post my reply to you as I figured out the solution!  Here is the syntax and steps that I used to accomplish my end results:

    Expr1: [SumOfColumn1]/([SumOfColumn1]+[SumOfColumn2])

    then in the field where I entered the expression I right-clicked, then clicked properties, then changed the format to percent and VIOLA!! that did the trick.

    Thank you for the help, your kick in the right direction was just what I needed to figure it out.  

    Friday, August 21, 2015 9:51 PM

All replies

  • Try this --

    Sum(Column1)/(Sum(Column1+Column2)) / 100


    Build a little, test a little

    • Proposed as answer by André Santo Friday, August 21, 2015 10:58 AM
    Friday, August 21, 2015 5:23 AM
  • Hi Karl, thanks so much for the help.  I've tried a couple of things and each time I don't get any results in the Expr1 field for my query.

    I have column1 grouped by sum

    I have column2 grouped by sum

    Then for the third column I have the expression written out as you suggested in the field field of the design view of the query.  I don't get any errors when I run it, but when the query is run the Sum of Column1 shows as it should as well the sum of column2 shows as it should, but then the third column just says Expr1 without any results.  I've tried a few things with regards to the grouped by field in the design view but more often then not those result in errors.  Any thoughts?

    Friday, August 21, 2015 9:45 PM
  • Hi Karl ... so no sooner did I post my reply to you as I figured out the solution!  Here is the syntax and steps that I used to accomplish my end results:

    Expr1: [SumOfColumn1]/([SumOfColumn1]+[SumOfColumn2])

    then in the field where I entered the expression I right-clicked, then clicked properties, then changed the format to percent and VIOLA!! that did the trick.

    Thank you for the help, your kick in the right direction was just what I needed to figure it out.  

    Friday, August 21, 2015 9:51 PM