Results 1 to 2 of 2
  1. #1
    Eskoraczewski is offline Novice
    Windows 2K Access 2007
    Join Date
    Jan 2014
    Posts
    4

    Summing a query column help

    Hi, so I have four columns of data:

    week number
    week end date
    id
    totalbyweek

    basically I wNt to sum the "totalbyweek" column if the ID ="e" and the id= "pg"- and then sum by week number


    so instead of having this example
    week 1 - pg - 1
    week 1 - e - 2


    week 1 - n - 2


    it reads as:
    week 1 - e - 3
    week 1 - n - 2


    i basically need to sum the e and n by week but the e needs to be the sum of e and pg... Any help?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Build an aggregate (Totals) query with conditional expressions.

    SELECT [week number], Sum(IIf([ID]="e" Or [ID]="pg", [totalbyweek], 0)) AS SumEPG, Sum(IIf([ID]="n", [totalbyweek], 0)) AS SumN FROM tablename GROUP BY [week number];


    Or build a report using Grouping & Sorting features with aggregate calcs in footers. This will allow display of detail records as well as summary calcs.

    Create a Group on week number. Use expressions in textboxes in Group and/or Report footers.

    =Sum(IIf([ID]="e" Or [ID]="pg", [totalbyweek], 0))

    =Sum(IIf([ID]="n", [totalbyweek], 0))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Summing Multiple Queries & Summing Time
    By WEJ in forum Queries
    Replies: 2
    Last Post: 10-04-2013, 04:46 PM
  2. A summing query?
    By russweb in forum Queries
    Replies: 8
    Last Post: 03-26-2012, 06:57 PM
  3. Replies: 1
    Last Post: 02-27-2012, 09:50 AM
  4. summing in a query
    By nparrillo in forum Queries
    Replies: 1
    Last Post: 04-11-2011, 10:37 AM
  5. Summing a column
    By nashr1928 in forum Forms
    Replies: 2
    Last Post: 05-10-2010, 05:42 PM

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