• Odd grouping levels (Access 2002)

    • This topic has 2 replies, 2 voices, and was last updated 22 years ago.
    Author
    Topic
    #385856

    Hi All!

    I have a query that pulls regional and national figures by activity category that results in something like this:
    Activity Regional Hours % National Hours %
    Sales Calls 1000 50 5000 50
    Sales Paperwork 500 25 2000 20
    Admin 500 25 3,000 30
    Leave 500 20 2,000 20

    If the %’s don’t line up right, it’s because they’re as a % of everything EXCEPT leave.

    What I need to do is set up grouping levels so that they come out so I can do this:

    Activity Regional Hours % National Hours %
    Sales Calls 1000 50 5000 50
    Sales Paperwork 500 25 2000 20

    Total Sales 1500 75 7,000 70
    Admin 500 25 3,000 30
    Total Core Hours 2000 100 10,000 100

    Leave 500 2,000
    Total Hours 2,500 12,000

    What I’ve done so far is create a calculated grouping level, Activity Line, that if the activity is Sales, then it’s group 1, for admin it’s group 2, then for leave it’s group 3. Then I made a running sum in the Activity Line group.

    Somehow, my totals don’t total. It SHOULD be just a matter of summing, but the percents don’t add up properly. Instead of Total Sales summing to 75, it’s summing to 60 (which is way too big to be a rounding error).

    If I can get past this hurdle, I’m sure the rest is just a matter of not displaying the % column when Activity=”Leave” (I hope).

    Has anyone had this problem before?

    TIA,

    Viewing 0 reply threads
    Author
    Replies
    • #667234

      Are you saying your query returns this:

      Activity Regional Hours % National Hours %
      Sales Calls 1000 50 5000 50
      Sales Paperwork 500 25 2000 20
      Admin 500 25 3,000 30
      Leave 500 20 2,000 20

      And your totals should come out like this:

      Totals Regional Hours % National Hours %
      Total Sales 1500 75 7,000 70
      Admin 500 25 3,000 30
      Total Core Hours 2000 100 10,000 100
      Leave 500 2,000
      Total Hours 2,500 12,000

      You can’t just add the percentages, you have to calculate the new percentages using a different denominator. 1500/2000 is 75%, but 1500/2500 is 60%. You used the overall total as the denominator for the original percentages so it’s still part of the equation when you add them up.

      • #667247

        Hi Charlotte:

        Actually, the problem I had was a rounding error. My calculations were based on the correct number (I don’t know if the totals looked wrong, but all the other %’s were of core hours, including leave), but it really was a rounding error. I had percentages in the query, then when I went to sum things on the report, it was _completely_ dropping what was after the decimal point.

        The solution? In my query, instead of Percentage as a type, I times’d everything by 100 so it would display as a full % with unlimited decimal places. Then when I added it all in the report, I also added Round(Sum([My Field]),0) so the totals would come out to 100% of core.

        As for the leave category, I just set the textbox to not display if we’re in the category that includes leave.

        Sorry for the subject of this being wrong. I was going to delete my post, but then I thought it might be useful to leave it because of the percentage lesson.

    Viewing 0 reply threads
    Reply To: Odd grouping levels (Access 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: