Results 1 to 5 of 5
  1. #1
    mlrucci is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2018
    Posts
    202

    Post 2 week intervals in Crosstab qry columns

    Good afternoon,


    I am attempting to create a crosstab query with the row headings as employee and the column header to show in two week intervals based on today's date and going back one year. I have created a from with txtDateStart0 as the start date to allow changes in the date as needed for recalculation for different start dates. To be clearer, I need a sum of hours for each employee of their sick time so see if they are out of compliance at any time within a date range in a two week interval. Example below. I am having difficulty with the column headers to calculate based on two week intervals. All I could fine is quarterly. Can anyone help?

    Employee 10/13/18 to 9/30/18 to
    10/13/17 9/30/17

    Frank 16 32
    Betty 8 10

  2. #2
    mlrucci is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2018
    Posts
    202
    My appologies,
    After posting the thread, I noticed that the format for my quick example was not the same as I inputted. please see below. My txtDateStart0 on the form is 10/13/18. There will be a total of 26 columns when completed so that I can see a full 2 years back from txtDateStart0

    Employee 10/13/18 to 10/13/17 09/30/18 to 09/30/17
    Frank 16 32
    Betty 8 10


    Thank you in advance for you assistance.

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    There will be a total of 26 columns when completed so that I can see a full 2 years back from txtDateStart0
    if 26 columns and 2 week intervals, that is 52 weeks

    suggest review the partition function in sql, which will get you your 2 week intervals, but your column headings cannot be sorted to provide the right order (they are text), so you will also need another column to count backwards and sort on that - perhaps use the datedff function to return weeks difference, it won't matter what the value is, 2, 4, 6 will sort the same as 1,2, 3 and won't be shown in your final query

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I see each column header is a full year, but 'rolling' by 2 weeks. Is that what you really want? It means data will be reported under multiple headings. Don't think PARTITION can accomplish that.

    This might need domain aggregate functions (DCount, DSum) in 26 calculated fields or textboxes.
    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.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    ahh - didn't notice that, thought it was 2 week periods, not a moving total, scrap partition then.

    On closer reading, I don't think the proposed solution meets the requirement anyway

    I need a sum of hours for each employee of their sick time so see if they are out of compliance at any time within a date range in a two week interval
    which implies over a two week period from any sick date. Analysing in two week periods doesn't work because someone may have had say 3 days in the second half of one period and 3 days in the first half of the next period.

    Think the OP needs to clarify

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

Similar Threads

  1. Replies: 13
    Last Post: 01-13-2016, 04:08 PM
  2. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  3. Zeros in crosstab columns
    By GraemeG in forum Queries
    Replies: 2
    Last Post: 06-09-2011, 04:00 AM
  4. Group by Week in a Crosstab Query
    By NMJones in forum Access
    Replies: 1
    Last Post: 06-24-2010, 04:09 PM
  5. Crosstab: Sum of Columns over Row
    By tommaccoy in forum Queries
    Replies: 0
    Last Post: 12-03-2008, 05:26 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