Results 1 to 4 of 4
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310

    Row total in a cross tab query

    Hi to all,
    I have a cross tab query that show totals per month.
    The outcome of the query is:
    Click image for larger version. 

Name:	Capture1.JPG 
Views:	20 
Size:	42.4 KB 
ID:	52455


    The cross tab query is:
    Code:
    TRANSFORM NZ(Count(tblBorrowedBooks.DateBorrowed),0) AS CountOfDateBorrowed
    SELECT Year([DateBorrowed]) AS SelectYear
    FROM tblBorrowedBooks
    GROUP BY Year([DateBorrowed])
    ORDER BY Year([DateBorrowed]) DESC
    PIVOT Format([DateBorrowed],"mmm") In (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);
    I want to add a new column after Dec to show the total for each year (example: horizontal total for the year 2024).


    Can this be done? How?

    Thank you
    Khalil

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Like this you mean?
    Attached Thumbnails Attached Thumbnails Totals Crosstab.png  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    just include a ttlCount column

    Code:
    TRANSFORM NZ(Count(tblBorrowedBooks.DateBorrowed),0) AS CountOfDateBorrowed
    SELECT Year([DateBorrowed]) AS SelectYear, count(dateBorrowed) as ttlCount
    FROM tblBorrowedBooks
    GROUP BY Year([DateBorrowed])
    ORDER BY Year([DateBorrowed]) DESC
    PIVOT Format([DateBorrowed],"mmm") In (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);
    it will appear before your Jan-Dec figures, but you can have it after as part of your visual formatting in a form or report

  4. #4
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310
    Hi,
    Thank you very much.
    Khalil

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

Similar Threads

  1. Replies: 4
    Last Post: 08-15-2017, 08:44 AM
  2. Replies: 3
    Last Post: 10-25-2012, 08:11 PM
  3. Replies: 2
    Last Post: 12-12-2010, 11:45 AM
  4. Adding rows on cross-tab query report
    By KahluaFawn in forum Reports
    Replies: 2
    Last Post: 02-18-2009, 10:09 AM
  5. access cross tab query
    By Hossam in forum Access
    Replies: 0
    Last Post: 11-10-2008, 06:01 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