Results 1 to 12 of 12
  1. #1
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152

    Calculating columns in crosstab query

    Hello.

    is there a way to calculate columns together in a crosstab query.


    The picture attached will help explain.
    I need to add the firt five columns to the sums already in the 6th column for example.
    As this is set for a report and currently I am doing the calculations in the report which is rgeat but takes too long to load, wheres the non calculated fields are instant.

    Is this possible?

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    This is untested as I didn't want to recreate your db.

    Insert a column and in the first line type
    Code:
    Sum Years 1-10: [Year1]+[Year2]+[Year3]+[Year4]+[Year5]+[Years6-10]
    If this does not work, then create a new query with this query as the record source and then insert the above in the second query. Use the second query as your record source for your report.

    Alan

  3. #3
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Sorry it would not let me create a new column. Also I do not understand how you mean create a new query from this existing crosstab query?

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    On the ribbon, click on create. Click on Query Design. Click on the tab Queries and select the crosstab query. Add the fields that you want in the new query. Insert a new column and put the expression in the first line of the new column.

    Alan

  5. #5
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    This doesnt make sense. Creating anew crosstab from the existing just gives the years so cannot create a valid corsstab query giving the correct responses?

  6. #6
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Sorry understand now. Cracked it.
    I have used the calculations in the report as new column headers it works!!
    Thanks

  7. #7
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Great Its just the totals now for each column. I can set this in normal view of the crosstab. But it does not show up in the report. I have to then add totals in the report design and these are the only things that remain unloaded unless I click on them or wait a very long time. Is there a way to include these in the crosstab somehow?

  8. #8
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    I don't understand your last thread. Have you made the last query the record source for your report? If you have, then everything should populate quickly and properly. Without seeing your database, I am only guessing as to what you are doing and am shooting in the dark at a target I cannot see.

    Alan

  9. #9
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Yeah thats right I now have the new query looking at the crosstab query. The new query populates the report and does populate the report quickly. However each column needs a total row. and to do this I can only use the totals function in the report design. which is still causing the load issue. Is there a way to incorporate a total row for each column at the query stage?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You can have a Totals row in a table or query but this will not translate into the report.

    You are using the report's grouping and sorting with summary calcs in footers? Don't know why this would take so long to load. Would have to examine the project. If you want to, make it available in attachment to post or upload to fileshare site and post link. Either way, remove confidential data and run Compact & Repair first.
    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.

  11. #11
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Quote Originally Posted by June7 View Post
    You can have a Totals row in a table or query but this will not translate into the report.

    You are using the report's grouping and sorting with summary calcs in footers? Don't know why this would take so long to load. Would have to examine the project. If you want to, make it available in attachment to post or upload to fileshare site and post link. Either way, remove confidential data and run Compact & Repair first.
    Yeah thats right I am using the grouping and sorting totals as footers. It loads very quickly when I open the report straight from the navigation pane when I am developing the dB. But when I load my "Apllication" that I have created which hides runtime etc so and try to open the report from a VBA command within a subform this is when it takes so long to load the totals row. It would be quite difficult for the dB to be sent to you without exposing confidential data, or atleast for you to understand how the report works if I take all the data out.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Yes, you would have to remove confidential data (phone, address). Could copy db, remove most records and dummy up the remainder for testing.

    Could show the code that opens the report, maybe we can see a problem there.
    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. Replies: 1
    Last Post: 01-24-2011, 03:03 PM
  2. Calculating the Sum of Mulitple Columns
    By ARickert in forum Queries
    Replies: 22
    Last Post: 12-27-2010, 09:06 PM
  3. Replies: 1
    Last Post: 02-05-2010, 08:33 AM
  4. Crosstab: Sum of Columns over Row
    By tommaccoy in forum Queries
    Replies: 0
    Last Post: 12-03-2008, 05:26 AM
  5. Replies: 2
    Last Post: 11-09-2005, 02:51 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