Results 1 to 8 of 8
  1. #1
    Euler is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    62

    Crosstab query question

    I want to create a crosstab query where I can get an average for a select number of row entries. In other words, let's say I have a database with three fields: days of the week, company name, hours worked. The row heading would be the days of the week, the column heading would be the company name and the values would be average hours worked. Now, let's say I just want the average for the group of Tuesday, Thursday and Friday instead of individual averages for each day. Is there a way to do this? Thank you.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    It is called a dynamic crosstab query.
    https://www.google.com/search?q=dyna...obile&ie=UTF-8
    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
    Euler is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    62
    I don't see how a dynamic crosstab query solves my problem.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    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

  5. #5
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    Is this what you mean?
    Code:
    TRANSFORM Avg(YourTable.HoursWorked) AS AvgHoursWorked SELECT YourTable.DayOfWeek
    FROM YourTable
    WHERE (((YourTable.DayOfWeek)="Tuesday" Or (YourTable.DayOfWeek)="Thursday" Or (YourTable.DayOfWeek)="Friday"))
    GROUP BY YourTable.DayOfWeek
    PIVOT YourTable.CompanyName;
    Groeten,

    Peter

  6. #6
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    Quote Originally Posted by Welshgasman View Post
    While I was posting my answer
    Groeten,

    Peter

  7. #7
    Euler is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    62
    No, this isn't what I mean because the three days are listed separately in the results. I want the results to show the aggregation in one row for those three days only. Nice try, though.

  8. #8
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Perhaps in order to enlighten us all as to what you really want, you could mock something up, as the answers provided to you so far (on both forums!), are giving you what you described you wanted in words, but apparently not what you really want in your head.
    A cross tab is quite specific in it's required elements, and possible layouts.

    So a picture paints a thousand stories. Get painting please.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Unique question about crosstab queries...
    By ChaseC in forum Programming
    Replies: 4
    Last Post: 10-03-2017, 07:15 AM
  2. Crosstab query question
    By AnnLillandFinn in forum Queries
    Replies: 2
    Last Post: 02-20-2016, 09:58 AM
  3. CrossTab Query Question
    By djclntn in forum Queries
    Replies: 1
    Last Post: 11-29-2011, 11:33 AM
  4. Crosstab Query Question
    By hnguyen1987 in forum Access
    Replies: 1
    Last Post: 08-20-2010, 12:54 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