Results 1 to 4 of 4
  1. #1
    klkeahey is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Posts
    2

    Calculating a field when a support Group By Field can be both blank and not blank


    I have query that I run with the following fields:
    Manager
    Emply ID
    Sales
    Units
    Commission

    My query calculates the commission based upon the total sales and units per employee. The problem is the same employee can have sales attributed to a manager and sales not attributed to a manager. When this happens, the unit and sales total double.
    Is it possible to have the query correctly calculate unit totals, sales total and the commission regardless of whether the manager field is Null or has data in it?
    I should have the Emply ID and Manager field are "Group By" fields.

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If it doesn't matter whether Manager is blank or not, you could just leave it out of the query altogether.

    Without seeing the query, this may not be correct, but Units and Total Sales should not "double" - there will be separate (but very likely different) values for the rows with and without a manager. That depends on how you calculated the Units and Total Sales values, though.

    If you do need the Manager value in the query, you could use a DLookup to get the manager for each employee from another table, and group by that expression too.

  3. #3
    klkeahey is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Posts
    2

    Thanks John

    Thanks John.

    I definitely need the managers as part of the query. The problem is managers are rearranged or assigned through out the month; therefore, the DLookup doesn't help either.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    OK. But if there can be multiple values of "Manager" (including blank) for each employee, then your query will contain multiple rows for each employee as well; that is how "Group By" works.

    What is your requirement exactly? Do you want total units & sales by employee, or do you want it broken down by Employee+Manager?

    When you run the query with manager in it, for employees appearing more than once are the values in Units and Sales different on each row, or are they the same? If they are the same, I suspect your query has an error in it.

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

Similar Threads

  1. Missing field if name blank
    By lewis1682 in forum Reports
    Replies: 1
    Last Post: 10-02-2013, 12:31 PM
  2. Replies: 3
    Last Post: 07-30-2013, 12:11 PM
  3. Null field blank
    By brobb56 in forum Reports
    Replies: 3
    Last Post: 09-26-2011, 12:15 PM
  4. Replies: 4
    Last Post: 09-06-2011, 02:20 PM
  5. Replies: 4
    Last Post: 05-11-2011, 03:06 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