Results 1 to 5 of 5
  1. #1
    SergeantMike is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2018
    Posts
    6

    Complex query?

    I have no idea if this can be done in Access or if I need to do this manually in Excel as I have been.

    I have counts from insects emerging from plants and I want to automate the calculation of the percentage that have emerged for each day. For example:

    Data in the Table
    PLANT DATE TimeEmerge NUM EMERGED
    A1-1 6-20-19 9:00 1
    A1-1 6-21-19 9:00 1
    A1-1 6-21-19 13:00 5
    A1-1 6-22-19 9:00 10
    A1-1 6-22-19 13:00 25
    A1-1 6-22-19 17:00 5



    This query generates
    SELECT T1.txtFarmPlotID, T1.intContNo, T1.dtePick, T1.BugFound, (SELECT Sum(qryRunningTotal.BugFound) AS Total FROM qryRunningTotal WHERE qryRunningTotal.dtePick <= T1.dtePick AND qryRunningTotal.txtFarmPlotID = t1.txtFarmPlotID AND qryRunningTotal.intContNo = T1.intContNo ) AS VarietyTotal, T1.[Elapsed Days], T1.intGallCount, T1.sngWeight
    FROM qryRunningTotal AS T1
    GROUP BY T1.txtFarmPlotID, T1.intContNo, T1.dtePick, T1.BugFound, T1.[Elapsed Days], T1.intGallCount, T1.sngWeight;



    this sheet
    PLANT DATE NUM EMERGED ACC EMERGED
    A1-1 6-20-19 1 1
    A1-1 6-21-19 5 6
    A1-1 6-22-19 34 40

    I would like to add an additional column of % emerged

    PLANT DATE NUM EMERGED ACC EMERGED % EMERGED
    A1-1 6-20-19 1 1 2.5
    A1-1 6-21-19 5 6 15
    A1-1 6-22-19 34 40 100

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,526
    yes, add the data in your table1 to the maindata.
    then run the summary query to get the %.

    Q1 to sum the plant total
    Q2 sum 1 day event,
    Q3 join Q1 & Q2 to get your final data with %.

  3. #3
    Cottonshirt is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Feb 2018
    Posts
    116
    SergeantMike said: I would like to add an additional column of % emerged
    I admit to being confused about what exactly it is you want to calculate. as far as I can tell from your data, 100% of bugs that have emerged, have emerged, so your calculation of % emerged will always be 100%.

    but the first row of your summary data says...

    PLANT DATE NUM EMERGED ACC EMERGED % EMERGED
    A1-1 6-20-19 1 1 2.5
    ...that one bug emerged today, and that is a total of 1 bugs that have emerged, and that is 2.5%.

    but 1 is not 2.5% of 1, so I'm just confused.

    maybe it would help if you were to clarify what you are trying to calculate.


    Cottonshirt

  4. #4
    SergeantMike is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2018
    Posts
    6
    Quote Originally Posted by Cottonshirt View Post
    I admit to being confused about what exactly it is you want to calculate. as far as I can tell from your data, 100% of bugs that have emerged, have emerged, so your calculation of % emerged will always be 100%.

    but the first row of your summary data says...



    ...that one bug emerged today, and that is a total of 1 bugs that have emerged, and that is 2.5%.

    but 1 is not 2.5% of 1, so I'm just confused.

    maybe it would help if you were to clarify what you are trying to calculate.


    Cottonshirt


    However, 1 is 2.5% of 40 which is the total number of bugs that emerged

  5. #5
    Cottonshirt is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Feb 2018
    Posts
    116
    okay, so you want to do several things,

    1. for each plant, count the number of bugs that emerged each day
    2. for each plant, sum the total number of bugs that have emerged on that plant, so far [totalsofar]
    3. calculate the daily total as a percentage of the [totalsofar]

    personally, I would do this in three queries, where each query does one distinct thing, as listed above.

    therefore, the answer to your original question: I would like to add an additional column of % emerged

    is, do it in a separate query.
    you would need to get T1.intGallCount and Sum(qryRunningTotal.BugFound) on the same row of your query, then calculate the percentage: (T1.intGallCount/Sum(qryRunningTotal.BugFound)) * 100


    good luck with your project,


    Cottonshirt

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

Similar Threads

  1. Replies: 8
    Last Post: 10-17-2018, 11:52 AM
  2. too complex query
    By ANSFO in forum Queries
    Replies: 2
    Last Post: 10-15-2018, 01:16 PM
  3. Need help with complex Query
    By drnld in forum Access
    Replies: 4
    Last Post: 12-08-2014, 02:02 PM
  4. Complex Query Help
    By Degs29 in forum Queries
    Replies: 9
    Last Post: 05-31-2013, 01:12 PM
  5. Help with complex Query
    By CEV in forum Queries
    Replies: 1
    Last Post: 03-12-2011, 06:54 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